When using: java -jar HelloWorld2.jar
the command needs to be issued in the folder containing the jar file.
That is where the java command needs to be issued.
Type: Posts; User: Norm
When using: java -jar HelloWorld2.jar
the command needs to be issued in the folder containing the jar file.
That is where the java command needs to be issued.
Options passed to the java command need to start with a -
java -jar TheJarFIlename.jar
Otherwise the java command thinks it is the name of a class -
Error: Could not find or load main class jar
What did you do to get that message?
Here is one way to get that error message:
The posted contents of the commands that you entered did not show what directory they were entered in making it hard to judge.
The jar command needs to be executed in the folder containing the...
I can not find a simple command on my system that does what you are trying to do. I make batch files for many of my projects to create the jar file.
Here are some examples:
@REM Make jar file ...
The Main.class file needs to be in the folder: MyPackage inside of the jar file. It looks like neither of the class files inside of the jar file are in the appropriate folder.
The jar command...
What is the contents of the package statement in the Main.java file?
The java program is looking for Main in the package Mypackage.
Note: Java is case sensitive. Mypackage is NOT the same as...
The advantage of using correctly created jar files is that with a properly installed JRE, double-clicking on the jar file will start the java program.
The jar file can be located anywhere. A...
The full class name includes the package: com.example.helloworld.Main
The full name needs to be given to the java command: java com.example.helloworld.Main
The com folder needs to be in the...