• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoClassDefFoundError - where to put Javamail JAR file?

 
James Brooks
Gunslinger
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
jar.gif
[Thumbnail for jar.gif]
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using the -classpath (or -cp) option of the java command.
 
James Brooks
Gunslinger
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20613
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
James Brooks
Gunslinger
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic