Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Exception in thread "main" java.lang.NoClassDefFoundError: sampl

Reply
Thread Tools

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

 
 
xcrazy
Guest
Posts: n/a
 
      04-20-2007
Hi, I know this is a common error, but this occurs only in some of my
programs.
I run java on windows XP SP2, jdk1.5
My sampl.java file is like this:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class swing_app {
public static void main(String[] args) {
JDesktopPane desktop = new JDesktopPane();
desktop.add(desktop,BorderLayout.CENTER);
JInternalFrame internalFrame = new JInternalFrame("Internal
Frame",true,true,true,true);
internalFrame.setBounds(50,50,200,100);
desktop.add(internalFrame,new Integer(1));
}
}

It compiles giving me a "sampl.class" file but when i type this
>java sampl

I get this error: - Exception in thread "main"
java.lang.NoClassDefFoundError: sampl

I don't get this error in a simple "Hello world" program.....
This is how i've set my paths:

Path=c:\j2sdkee1.3.1\bin;%SystemRoot%\system32;%Sy stemRoot%;%SystemRoot
%\system32\WBEM;%SYSTEMROOT%\system32\WBEMC:
\PROGRA~1\COMMON~1\AUTODE~1;.;C:\Java\jdk1.5.0_09\ bin;c:\Java
\jdk1.5.0_09\lib;

CLASSPATH= .;C:\Java\jdk1.5.0_09\lib;C:\Java\jdk1.5.0_09\bin; C:
\j2sdkee1.3.1\bin;

Please help!!

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      04-20-2007
On Apr 20, 1:56 pm, xcrazy <sharathg...@gmail.com> wrote:
> Hi, I know this is a common error, ..


Multi-posting instead of cross-posting?
Please refrain from multi-posting, in future.
<http://www.physci.org/codes/javafaq.html#xpost>

Andrew T.

 
Reply With Quote
 
 
 
 
micro
Guest
Posts: n/a
 
      04-20-2007
On Apr 20, 6:56 am, xcrazy <sharathg...@gmail.com> wrote:
> Hi, I know this is a common error, but this occurs only in some of my
> programs.
> I run java on windows XP SP2, jdk1.5
> My sampl.java file is like this:
>
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
>
> class swing_app {
> public static void main(String[] args) {
> JDesktopPane desktop = new JDesktopPane();
> desktop.add(desktop,BorderLayout.CENTER);
> JInternalFrame internalFrame = new JInternalFrame("Internal
> Frame",true,true,true,true);
> internalFrame.setBounds(50,50,200,100);
> desktop.add(internalFrame,new Integer(1));
> }
>
> }
>
> It compiles giving me a "sampl.class" file but when i type this>java sampl
>
> I get this error: - Exception in thread "main"
> java.lang.NoClassDefFoundError: sampl
>


first :note that your class named "swing_app" not "sampl" it wil
compile giving you a "swing_app.class"
second :you should not add acontainer to it self

> desktop.add(desktop,BorderLayout.CENTER);

third you are using an internal frame so you should note that you will
not be able to see any thing unless you put that in a desktoppane then
in a frame
so try the following it will work:
import javax.swing.*;

class SwingApp {
public static void main(String[] args) {
JFrame f= new JFrame();
f.setSize(300, 300);
JDesktopPane desktop = new JDesktopPane();
f.setContentPane(desktop);
JInternalFrame internalFrame = new
JInternalFrame("internal frame");
internalFrame.setBounds(50,50,200,100);
internalFrame.setVisible(true);
desktop.add(internalFrame,null);
f.setVisible(true);
}

}

 
Reply With Quote
 
micro
Guest
Posts: n/a
 
      04-20-2007
On Apr 20, 6:56 am, xcrazy <sharathg...@gmail.com> wrote:
> Hi, I know this is a common error, but this occurs only in some of my
> programs.
> I run java on windows XP SP2, jdk1.5
> My sampl.java file is like this:
>
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
>
> class swing_app {
> public static void main(String[] args) {
> JDesktopPane desktop = new JDesktopPane();
> desktop.add(desktop,BorderLayout.CENTER);
> JInternalFrame internalFrame = new JInternalFrame("Internal
> Frame",true,true,true,true);
> internalFrame.setBounds(50,50,200,100);
> desktop.add(internalFrame,new Integer(1));
> }
>
> }
>
> It compiles giving me a "sampl.class" file but when i type this>java sampl
>
> I get this error: - Exception in thread "main"
> java.lang.NoClassDefFoundError: sampl
>


first :note that your class named "swing_app" not "sampl" it wil
compile giving you a "swing_app.class"
second :you should not add acontainer to it self

> desktop.add(desktop,BorderLayout.CENTER);

third you are using an internal frame so you should note that you will
not be able to see any thing unless you put that in a desktoppane then
in a frame
so try the following it will work:
import javax.swing.*;

class SwingApp {
public static void main(String[] args) {
JFrame f= new JFrame();
f.setSize(300, 300);
JDesktopPane desktop = new JDesktopPane();
f.setContentPane(desktop);
JInternalFrame internalFrame = new
JInternalFrame("internal frame");
internalFrame.setBounds(50,50,200,100);
internalFrame.setVisible(true);
desktop.add(internalFrame,null);
f.setVisible(true);
}

}

 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      04-20-2007
xcrazy <sharathg...@gmail.com> wrote:
>> Hi, I know this is a common error, but this occurs only in some of my
>> programs.
>> I run java on windows XP SP2, jdk1.5
>> My sampl.java file is like this:
>>
>> import java.awt.*;
>> import java.awt.event.*;
>> import javax.swing.*;
>>
>> class swing_app {


Class names should start with an upper-case letter, not contain underscores
and start each word part with an upper-case letter, thus "SwingApp", by
convention.

--
Lew
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception of type 'System.Web.HttpUnhandledException' wasthrown.Exception has been thrown by the target of an invocation.System.WebSystem.Exception jobs ASP .Net 1 11-16-2007 05:57 PM
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
Terminating a thread from the main thread Charles A. Lackman ASP .Net 3 12-09-2004 02:12 PM
"Thread was being aborted" error from WebApp using Thread.Sleep. Stephen Miller ASP .Net 3 07-01-2004 11:50 PM
perl 5.8.2/3 - thread started by a thread pawo Perl 0 02-16-2004 01:18 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57