tags:

views:

64

answers:

1

Hello

I'm trying to send an email using JavaMail API. I have jdk 1.5 installed in my home directory from self-extracting binary. I'm on Ubintu 9.10

I compile the program using the next command:

~/jdk1.5.0_22/bin/javac -classpath ~/jdk1.5.0_22/jre/lib/javamail-1.4.3/mail.jar:~/jdk1.5.0_22/jre/lib/jaf-1.1.1/activation.jar hw.java

It compiles OK. As you can see I have specified the path to mail.jar and activation.jar Now I try to run the app using the next command:

~/jdk1.5.0_22/bin/java -classpath ~/jdk1.5.0_22/jre/lib/jaf-1.1.1/activation.jar:~/jdk1.5.0_22/jre/lib/javamail-1.4.3/mail.jar:. HelloWorldApp

I get an exception java.lang.NoClassDefFoundError: javax/mail/Address

Why can it find classes when compiling and cannot do it when running? How to correctly run my app?

Thanks in advance

A: 

That class should come from your mail.jar. I'm not sure your classpath is being parsed properly. The tilde (~) is a shell function and needs expanding before being sent to the Java process. Have you tried removing the ~ and replacing with /home/{whatever} ? I suspect that's the issue.

Brian Agnew
the class comes from mail.jar, not activation
Bozho
Ah. You're right. Corrected
Brian Agnew
Yes, you're right. I replaced ~ and it worked fine.Though it compiled ok with ~
smsrecv
I note your classpath is reversed between the compilation and run scenarios. Not sure if that makes a difference...
Brian Agnew
No differenece. Only that it complains about some class in activation.jar rather than in mail.jar
smsrecv