Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes NoClassDefFoundError - where to put Javamail JAR file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "NoClassDefFoundError - where to put Javamail JAR file?" Watch "NoClassDefFoundError - where to put Javamail JAR file?" New topic
Author

NoClassDefFoundError - where to put Javamail JAR file?

James Brooks
Gunslinger
Ranch Hand

Joined: Aug 17, 2006
Posts: 165
Hi all,

I have a task running on my WS2003 machine as inforadmin.PASCOUTIL via the task scheduler ( "C:\Program Files\Java\jdk1.6.0_13\jre\bin\java.exe" -jar "C:\CMMS_SCADA.jar" ). When I'm logged on as this user, I can run the jar file by double-clicking on it, but the task scheduler throws the NoClassDefFoundError pointing to javax.mail. I assume this as a javamail JAR file placement issue? I've attached a .gif showing the screenshot of this JAR file on the local computer, so if anyone would like to look and comment, I would greatly appreciate it.


[Thumbnail for jar.gif]



Hello. My name is Inigo Montoya. You killed my father. Prepare to die.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Try using the -classpath (or -cp) option of the java command.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
James Brooks
Gunslinger
Ranch Hand

Joined: Aug 17, 2006
Posts: 165
Wouter Oet wrote:Try using the -classpath (or -cp) option of the java command.


I placed the mail jar in the root of the C drive, then changed the task to the following:

"C:\Program Files\Java\jdk1.6.0_13\jre\bin\java.exe" -cp "C:\mail.jar" -jar "C:\CMMS_SCADA.jar"

I still got the same error. Any ideas?

Thank you!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19674
    
  18

When you use JAR files and the -jar flag, the class path is ignored. Try putting the JavaMail JAR file in a folder relative to your JAR file, then adding it to the Class-Path directive in your MANIFEST.MF file.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
James Brooks
Gunslinger
Ranch Hand

Joined: Aug 17, 2006
Posts: 165
Rob Prime wrote:When you use JAR files and the -jar flag, the class path is ignored. Try putting the JavaMail JAR file in a folder relative to your JAR file, then adding it to the Class-Path directive in your MANIFEST.MF file.


Well, I'm using Netbeans, so I don't know of a way of modifying the manifest file. I've put the javamail JAR in both the compile and run-time libraries in Netbeans, but am still getting this error from the JAR that is generated from my project (the JAR in the dist path of my Netbeans project). Do I maybe need to look at building this without the use of Netbeans, so that I have more granularity of control? Surely Netbeans has the capabilities to do what I am wanting to do; maybe I'm just missing a step somewhere? Again, I can double-click the JAR file, and it runs, but when run via the task scheduler under those same account privileges, that's when I get the error.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NoClassDefFoundError - where to put Javamail JAR file?