Exception in thread "main" java.lang.NoClassDefFoundError: SendMailTLSDFC

D

deepak

Hi, I have created a java file for sending a file to my mail. I am
using mail.jar file. I am able to create .class file properly. But am
unable to run this file using java command on command prompt.
javac -cp D:\mail.jar SendMailTLSDFC.java
above command is working properly.
It creates 2 class as mentioned below
SendMailTLSDFC$1.class
SendMailTLSDFC.class

but when i am trying to run following command I am getting an error.
java -cp D:\mail.jar SendMailTLSDFC
Exception in thread "main" java.lang.NoClassDefFoundError:
SendMailTLSDFC

Kindly help
 
G

GGolf

Hi, I have created a java file for sending a file to my mail. I am
using mail.jar file. I am able to create .class file properly. But am
unable to run this file using java command on command prompt.
javac -cp D:\mail.jar SendMailTLSDFC.java
above command is working properly.
It creates 2 class as mentioned below
SendMailTLSDFC$1.class
SendMailTLSDFC.class

but when i am trying to run following command I am getting an error.
java -cp D:\mail.jar SendMailTLSDFC
Exception in thread "main" java.lang.NoClassDefFoundError:
SendMailTLSDFC

Did you try adding the current folder (.) to the classpath?
 
L

Lew

GGolf said:
deepak said:
Hi, I have created a java [sic] file for sending a file to my mail. I am
using mail.jar file. I am able to create .class file properly. But am
unable to run this file using java command on command prompt.
javac -cp D:\mail.jar SendMailTLSDFC.java
above command is working properly.
It creates 2 class as mentioned below
SendMailTLSDFC$1.class
SendMailTLSDFC.class

but when i am trying to run following command I am getting an error.
java -cp D:\mail.jar SendMailTLSDFC
Exception in thread "main" java.lang.NoClassDefFoundError:
SendMailTLSDFC

Did you try adding the current folder (.) to the classpath?

In addition to GGolf's fine advice, which should solve that immediate problem, let me add a couple of extras:

- http://sscce.org/
This fine discussion of the Simple, Self-Contained Compilable (Correct) Example (SSCCE) by Andrew Thompson will help you two ways. Creating an exampleoften reveals the problem to you before you post your question, and the example isolates your issue and makes it easier for people to respond sensibly. GGolf was clever to figure out your issue without an SSCCE.

- Use packages.
You put 'SendMailTLSDFC' in the default package, or "no-package" package. Don't do that.

Also, study the Java tutorial and other documentation on classpaths.
 
D

deepak

Hi, I have created a java file for sending a file to my mail. I am
using mail.jar file. I am able to create .class file properly. But am
unable to run this file using java command on command prompt.
javac -cp D:\mail.jar SendMailTLSDFC.java
above command is working properly.
It creates 2 class as mentioned below
SendMailTLSDFC$1.class
SendMailTLSDFC.class

but when i am trying to run following command I am getting an error.
java -cp D:\mail.jar SendMailTLSDFC
Exception in thread "main" java.lang.NoClassDefFoundError:
SendMailTLSDFC

Kindly help


Hi,
Thanks so much for your reply GGolf and Lew.
GGolf, I tried . also and I got the result as shown below.
D:\project>java . SendMailTLSDFC
Exception in thread "main" java.lang.NoClassDefFoundError: /

Lew,
I had used packages but i just removed it from the current file before posting the question here just reduce the complexities.

Kindly help
 
P

Paul Cager

I tried . also and I got the result as shown below.
D:\project>java . SendMailTLSDFC
Exception in thread "main" java.lang.NoClassDefFoundError: /

You need

java -cp . SendMailTLSDFC

Otherwise the java command assumes "." is the name of the class you
are trying to run.
 
L

Lew

Paul said:
You need

java -cp . SendMailTLSDFC

Otherwise the java command assumes "." is the name of the class you
are trying to run.

Deepak, you should read the documentation on the "javac" and "java" commands.

Randomly tossing strings into your command isn't nearly as effective as
looking up the correct syntax and using it.
 
G

GGolf

You need

java -cp . SendMailTLSDFC

Otherwise the java command assumes "." is the name of the class you
are trying to run.

To the OP: You'll need mail.jar on the classpath too, so the command
will be:

java -cp D:\mail.jar;. SendMailTLSDFC
 
D

deepak

Thanks a lot evrybody,
java -cp D:\mail.jar;. SendMailTLSDFC
Above command worked.

Deepak
:)
 
L

Lew

deepak said:
Thanks a lot evrybody,
java -cp D:\mail.jar;. SendMailTLSDFC
Above command worked.

Thank you very much for showing us what worked.

(P.S. - Please do not top-post.)
 
R

Roedy Green

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top