Remote access to files type * .jar

0

Does anyone know if it is possible to have a group of jars on disk and that the java projects access it as a reference, without having to include them in the project itself, and thus make it lighter ?. They told me that it was possible to add in the classpath of the pc, but sincerely I never heard or seen something like that.

    
asked by Carlos 26.01.2017 в 16:55
source

1 answer

0

Yes it is possible. For example, you can have the following structure on your disk (assuming * -nix systems):

/opt
- /carlos
  - /comun
    + lib1.jar
  - /apps
    + miapp.jar

Then, your application could be executed from a terminal with the following steps:

$ cd /opt/carlos/apps
$ java -cp .:/opt/carlos/comun/lib1.jar -jar miapp.jar com.paquete.principal.ClasePrincipal

The same example above but for Windows:

C:\opt
- \carlos
  - \comun
    + lib1.jar
  - \apps
    + miapp.jar

Command:

$ C:
$ cd C:\opt\carlos\apps
$ java -cp .;C:\opt\carlos\comun\lib1.jar -jar miapp.jar com.paquete.principal.ClasePrincipal
    
answered by 26.01.2017 в 20:43