Mailinglist Archive: opensuse (911 mails)

< Previous Next >
Re: [opensuse] jar file?
Xen schreef op 06-12-2015 16:47:

Java classpaths that contain jars must
usually be explicitly mentioned, ie. a classpath would explicitly
contain the .jar, and not just its containing directory.

What I mean is that to use a .jar library in a java program, you would do something like:

java -cp path-to-jar-file/file.jar path-to-my-own-program

such as

java -cp lib/junit.jar org.mydomain.myprogram.myclass

to execute a program with the junit library, if that library is in that path

and you would the same for compilation:

javac -cp lib/junit.jar org/mydomain/myprogram/

Most jar files you come across would usually contain libraries, but they can also contain applications or web-apps (might have different extension) running in an application server (e.g. Tomcat). Typically a java program could or would ship as one or more jars for its own class files, and with jar files for every library used.

Some libraries split their classes into a jar for "interface" and a jar for "implementation" so you might have something like log4j-api.jar and log4j-core.jar.

Correct me if I'm wrong about something.


There are tools like Ant that automate this process somewhat with
things you could call project build files.

Maven is another one, and the third popular one is called Gradle I believe.

Normally you can use a zip tool to see the contents of the file, so
perhaps the "Ark" program would also be able to open it.


Thomas Taylor schreef op 06-12-2015 16:15:
How does one open and use a *.jar file?

Thanks, Tom KG7CFC


Failure seldom stops you. What stops you is the fear of failure.
- Jack Lemmon

^^ --... ...-- / -.- --. --... -.-. ..-. -.-.

Tom Taylor KG7CFC
openSUSE 13.1 (64-bit), Kernel 3.11.6-4-default,
KDE 4.11.2, AMD A8-7600, GeForce GTX 740 T/PCIe/
16GB RAM -- 3x1.5TB sata2 -- 128GB-SSD
FF 37.0, claws-mail 3.10.1
registered linux user 263467
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >