I have recently developed some java applications that i want others to run on their machines.
I did some research and now know that to distribute java code you need to create .jar file.
Well i did that, but when I am distributed those file it runs on some computers but on others it return an error saying: “Main class could not found”.
- Is there any problem with JRE version.
- How would a user know that on which version he/she should run the application.
- can i package the correct jre version with my app/jar file. how??
- Are jar files not compatible with other version of jre except in which they are compiled.
Option1: Create a manifest file with entry as below and include in the jar:
Option2: Just mention your
Mainclass name while running the program e.g. if youjarname ismyprogram.jarand main class isMainProgramthen run the program as below:If your
MainProgramtakes some arguments, them pass them as well in the command line e.g.