Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
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
Paul Clapham
Ron McLeod
Jeanne Boyarsky
Tim Cooke
Sheriffs:
Liutauras Vilda
paul wheaton
Henry Wong
Saloon Keepers:
Tim Moores
Tim Holloway
Stephan van Hulst
Carey Brown
Frits Walraven
Bartenders:
Piet Souris
Himai Minh
Forum:
Beginning Java
Executing a java program from a jar
Gsan Sangle
Greenhorn
Posts: 3
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi all,
I have a the following question :
i have a class that is wrapped up in a jar , the class has a main method.
the manifest file does not contain the "MainClass :" entry.
i want to exeute the class with main function.
Can any help me ?
Christophe Verré
Sheriff
Posts: 14691
16
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
java
-jar myjar.jar myclass
(Make sure the CLASSPATH is set properly)
[My Blog]
All roads lead to JavaRanch
Gsan Sangle
Greenhorn
Posts: 3
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
my jre/bin folder does not contain the .java file...
how do i set the path var, n wat exactly should be it be set to ?
Christophe Verré
Sheriff
Posts: 14691
16
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Let's say your JAR file is called "myjar.jar".
Let's say the class containing your main method is called "MyClass.class"
1. Go to the directory where myjar.jar is
2. Execute : java -cp . -jar myjar.jar MyClass
This will launch MyClass contained in myjar.jar
You don't need the java file.
[My Blog]
All roads lead to JavaRanch
Gsan Sangle
Greenhorn
Posts: 3
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Got the following error :
Failed to load Main-Class manifest attribute from
c:\extJars\abc_classes.jar
The manifest file does not contain the req entry.
Can it still be executed without the entry ?
Christophe Verré
Sheriff
Posts: 14691
16
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Oops sorry, I misread your post.
Yes, I think you'll have to add this entry into the manifest file.
[My Blog]
All roads lead to JavaRanch
Joanne Neal
Rancher
Posts: 3742
16
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
If you don't have a MainClass entry in your manifest you can't use the -jar option. Just add the jar file to your class path.
java -cp myjar.jar MyClass
Joanne
Story like this gets better after being told a few times. Or maybe it's just a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
JAR from NetBeans
running a class in a jar ......
how to specify a class file in jar
NoClassDefFoundError running a jar file from the command line
jar
More...