• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

The jar file wouldnt run

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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??
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 '.'.
 
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic