0

I am able to compile code but while running it is throughing classnotfound

C:\Users\Desktop\New>javac -classpath java-mail-1.4.4.jar SendMail.java

C:\Users\Desktop\New>java -classpath java-mail-1.4.4.jar SendMail

Exception in thread "main" java.lang.NoClassDefFoundError: SendMail
Caused by: java.lang.ClassNotFoundException: SendMail
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: SendMail.  Program will exit.

Can you suggest how to solve this?

3
  • does the SendMail.class exist in the C:\Users\Desktop\New path ? Commented Oct 29, 2014 at 11:19
  • mail.jar missing in your class path. Commented Oct 29, 2014 at 11:20
  • @VaibhavJain no then it would have thrown java.lang.ClassNotFound exception Commented Oct 29, 2014 at 11:23

2 Answers 2

1

Try using below commands

To compile java class

javac -classpath .;<jar file path>; Abc.java

To execute java class

java -classpath .;<jar file path>; Abc

Sign up to request clarification or add additional context in comments.

Comments

0

Try using:

Windows

java -classpath java-mail-1.4.4.jar;. SendMail
                    note this  ----^

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.