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".
Option1: Create a manifest file with entry as below and include in the jar:
Main-Class: MainProgram
Option2: Just mention your Main
class name while running the program e.g. if you jar
name is myprogram.jar
and main class is MainProgram
then run the program as below:
java -cp myprogram.jar MainProgram
If your MainProgram
takes some arguments, them pass them as well in the command line e.g.
java -cp myprogram.jar MainProgram argument1 argument2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With