This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Jar doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Jar doubt" Watch "Jar doubt" New topic

Jar doubt

Ranch Hand

Joined: Apr 04, 2007
Posts: 188
1>suppose i wrote a program called which is in package ab
2>now the HelloUsa.class files ie i created a jar file called prasanna.jar
3>now i put the(my prasanna.jar) jar file in .../jre/lib/ext
4>Actually my program should run when i execute java HelloUsa even if there is no .class files in my current dir for where i compile

is it right??
Rob Spoor

Joined: Oct 27, 2005
Posts: 19908

Not quite.

Because the class is in a package, the .class file should be in a folder called ab in the JAR file, and you should call the app using "java ab.HelloUSA". You are 100% correct about not needing to specify a classpath because the JAR file is in the /jre/lib/ext folder.

How To Ask Questions How To Answer Questions
subject: Jar doubt