Java class and jar

AXISHK
AXISHK used Ask the Experts™
on
What's the difference between java class (.class) and .jar ? Can I say .jar may contains serveral java classes ?

If there are serveral .class inside a .jar, how can I know which class to run first when I run the jar file ?

Thx
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Full-stack Java Developer
Commented:
Yes, there can be many classes in many packages in .jar file.

You specify which is the main class in the manifest:

https://docs.oracle.com/javase/tutorial/deployment/jar/appman.html

Main class needs to contain main method (public static void main(String[] args) )
Also just to clarify a .class file is compiled java code.  A .Jar is just a zipped archive file.  You can rename the extension to .zip and uncompress it with any zip tool.

Author

Commented:
Thx

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial