This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Java in General and the fly likes jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "jar file" Watch "jar file" New topic

jar file

Barry Higgins
Ranch Hand

Joined: Jun 05, 2003
Posts: 89
Hi everybody,
I'm having a bit of a problem here and I hoping someone can help with.
I've got my class file (which now contains little more than a hello world statment!) and my manifest
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.5.3
Created-By: 1.4.0_02-b02 (Sun Microsystems Inc.)
Main-Class: WEB-INF/classes/newsfeed_upload/action/newsfeedUpload
however when I try to access the jar file
containing them, calling
java -jar newsfeed_upload.jar I get this exception:
Exception in thread "main" java.lang.NoClassDefFoundError: WEB-INF/classes/newsf
eed_upload/action/newsfeedUpload (wrong name: newsfeed_upload/action/newsfeedUpl
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClassInternal(
Thanks v. much,
Joel McNary

Joined: Aug 20, 2001
Posts: 1824

Two things:
1). Unless WEB-INF/classes is part of the package name of your class (and odds are 99.9999% that they aren't), then you should not specify them in the class name. You class name should not be a path, but rather the fully-qualified class name (newsfeed_upload.action.newsfeedUpload).
2). Your jar structure should be {ROOT}/newsfeed_upload/action/newsfeedUpload.class
If you have the WEB-INF and classes directory in there (which I am assuming that you are, based on how you structured your Main-Class attribute) your class will not be found.

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Barry Higgins
Ranch Hand

Joined: Jun 05, 2003
Posts: 89
Thanks Joel,
I can't believe I missed that one!
I agree. Here's the link:
subject: jar file
It's not a secret anymore!