Compiled OK, but NoClassDefFoundError on startup

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

I will compile the program using the following 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 indicated the path to mail.jar and activ.jar. Now I am trying to start the application using the following 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 0.3 /mail.jar :. HelloWorldApp

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

Why can it find classes at compilation and cannot do this at startup? How to launch my application?

Thank you in advance

+3
source share
1 answer

This class should consist of yours mail.jar. I'm not sure your class path is being parsed correctly. Tilde (~) is a shell function and needs to be expanded before being sent to the Java process. Have you tried to remove ~ and replace with /home/{whatever}? I suspect a problem.

+2
source

Source: https://habr.com/ru/post/1723599/


All Articles