Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
Members have full access to the forums. Advertisements are removed for registered users.
So they need the classpath or they do not need the classpath
The CLASSPATH setting will be ignored when they run "java -jar YourProgram.jar". So in that sense they don't need it.
When you run an executable jar the classpath comes from what is specified in the manifest. That's why if your program is not running on another machine we need to see the details - the command, the output, the manifest file, at least.
If you are testing your program on another machine then installing the JDK on that machine was not a good move. The aim is to run your program on another computer without altering its settings. That's quite possible (and is the "ordinary" state of affairs) and if corrections need to be made, they need to be made to how your are creating the jar file.
jar cfmv MessageBoxCreator.jar mainClass.txt MessageBoxCreator.class MainClass.class MainClass$1.class
Have you created a manifest file?
Created-By: 1.7.0_02 (Oracle Corporation)
The OP never posted the console when the jar was executed from the commandline.
The one posting was for the case where the jar file was not seen by the java command, probably because the OP was in the wrong folder or misspelled the name of the jar file. Hard to say.
This happend a month before when i exported it from eclipse?
When are you going to try what I suggested in post #3 & #11?
i no longer have the error?
not to disrespect you but i did already just without everything, like the same exact example you posted
I got the same error message as you reported when I entered an madeup jar file name. If the file had been there you get a different error message. My assumption was that either the file was in another folder or the name was misspelled. Here's what I get when java finds a jar without a manifest:
My conclusion was that a thorough test had not been done.Microsoft Windows XP [Version 5.1.2600]
D:\JavaDevelopment\Testing\ForumQuestions5>java -jar hsa.jar
Failed to load Main-Class manifest attribute from
No In Post #11
Microsoft Windows XP [Version 5.1.2600]
D:\JavaDevelopment\Testing\ForumQuestions7>java -jar asdfasdf.jar
Unable to access jarfile asdfasdf.jar
Was your example, everything was correct and when i double clicked it it didnt open either
You get better error messages when you manually enter the java -jar command.
I don't remember that you did that, copied the command prompt window and posted it.
"Unable to access jarfile MessageBoxCreator.jar "
Was My Error..
That can mean there is no jar file with that name in that folder.
But you never posted the console window contents that shows the name of the folder.
You never did a dir command to show what was in the folder.
everthing was correct i did it 5 times and changes cd
Famous words.everthing was correct