Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #13466

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

From Lew <lewbloch@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Exception in thread "main" java.lang.NoClassDefFoundError: SendMailTLSDFC
Date 2012-04-10 10:16 -0700
Organization http://groups.google.com
Message-ID <23393087.261.1334078197190.JavaMail.geo-discussion-forums@pbjk8> (permalink)
References <cc382f4c-8985-491e-ac7e-f4c71e07bd71@9g2000yqp.googlegroups.com> <jm1cen$41b$1@speranza.aioe.org>

Show all headers | View raw


GGolf wrote:
> deepak wrote:
> > 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 example often 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.

-- 
Lew

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Exception in thread "main" java.lang.NoClassDefFoundError: SendMailTLSDFC deepak <deepak.vaswani@gmail.com> - 2012-04-10 01:40 -0700
  Re: Exception in thread "main" java.lang.NoClassDefFoundError: SendMailTLSDFC GGolf <invalid@invalid.com> - 2012-04-10 18:56 +0530
    Re: Exception in thread "main" java.lang.NoClassDefFoundError: SendMailTLSDFC Lew <lewbloch@gmail.com> - 2012-04-10 10:16 -0700
    Re: Exception in thread "main" java.lang.NoClassDefFoundError: SendMailTLSDFC Roedy Green <see_website@mindprod.com.invalid> - 2012-04-29 07:52 -0700
  Re: Exception in thread "main" java.lang.NoClassDefFoundError: SendMailTLSDFC deepak <deepak.vaswani@gmail.com> - 2012-04-11 04:19 -0700
    Re: Exception in thread "main" java.lang.NoClassDefFoundError: SendMailTLSDFC Paul Cager <paul.cager@googlemail.com> - 2012-04-11 05:44 -0700
      Re: Exception in thread "main" java.lang.NoClassDefFoundError: SendMailTLSDFC Lew <noone@lewscanon.com> - 2012-04-11 08:11 -0700
      Re: Exception in thread "main" java.lang.NoClassDefFoundError: SendMailTLSDFC GGolf <invalid@invalid.com> - 2012-04-12 07:38 +0530
        Re: Exception in thread "main" java.lang.NoClassDefFoundError: SendMailTLSDFC Lew <lewbloch@gmail.com> - 2012-04-12 10:47 -0700
  Re: Exception in thread "main" java.lang.NoClassDefFoundError: SendMailTLSDFC deepak <deepak.vaswani@gmail.com> - 2012-04-13 07:45 -0700
    Re: Exception in thread "main" java.lang.NoClassDefFoundError: SendMailTLSDFC Lew <lewbloch@gmail.com> - 2012-04-13 10:24 -0700

csiph-web