Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The jar file wouldnt run

 
rohu meti
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am begginer in Java. I tried to run Jar file from my desktop by double click or using command prompt. I created manifest and gave the class name [package name].[class name] of my java file.
With the command prompt I manage to create the class then jar file on desktop . The problem come when I try double click the jar file it just wont start. When I try to run it from the CMD Error ' the directory couldnt be found and some times It says main class couldnt be found. what shall i do??
 
Tony Docherty
Bartender
Posts: 3054
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What command did you issue from the command line?
 
rohu meti
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:What command did you issue from the command line?


1. javac : [Youtube.java]
-----I got class name: Youtube.class
2. Jar cfm Youtube.jar manifest.txt example1.Youtube.class (as my class in inside the package name example1)
error comes

when i try writing with out package name
Jar cfm Youtube.jar manifest.txt Youtube.class
Youtube.jar would be created on desktop

however double clicking not work
when i give this cmd in the cmd promt;
java -jar Youtube.jar
error main class not found prompt


java -jar [name of my jar file].jar
 
Tony Docherty
Bartender
Posts: 3054
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2. Jar cfm Youtube.jar manifest.txt example1.Youtube.class (as my class in inside the package name example1)


Assuming you are running the command from the parent directory of example1 on a windows machine, that should be:

You specify the file as a file path not as a Java package + name ie use '\' rather than '.'.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic