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


Groups > comp.lang.java.gui > #1501 > unrolled thread

Exception in thread "main

Started by"xcrazy" <xcrazy@THRWHITE.remove-dii-this>
First post2011-04-27 15:33 +0000
Last post2011-04-27 15:33 +0000
Articles 4 — 3 participants

Back to article view | Back to comp.lang.java.gui


Contents

  Exception in thread "main "xcrazy" <xcrazy@THRWHITE.remove-dii-this> - 2011-04-27 15:33 +0000
    Re: Exception in thread " "Knute Johnson" <knute.johnson@THRWHITE.remove-dii-this> - 2011-04-27 15:33 +0000
      Re: Exception in thread " "tar" <tar@THRWHITE.remove-dii-this> - 2011-04-27 15:33 +0000
        Re: Exception in thread " "Knute Johnson" <knute.johnson@THRWHITE.remove-dii-this> - 2011-04-27 15:33 +0000

#1501 — Exception in thread "main

From"xcrazy" <xcrazy@THRWHITE.remove-dii-this>
Date2011-04-27 15:33 +0000
SubjectException in thread "main
Message-ID<1177041518.814994.247180@q75g2000hsh.googlegroups.com>
  To: comp.lang.java.gui
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;%SystemRoot%;
%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!!

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#1503 — Re: Exception in thread "

From"Knute Johnson" <knute.johnson@THRWHITE.remove-dii-this>
Date2011-04-27 15:33 +0000
SubjectRe: Exception in thread "
Message-ID<rsXVh.594122$BK1.242910@newsfe13.lga>
In reply to#1501
  To: comp.lang.java.gui
xcrazy 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
> 
> 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;%SystemRoot%;
> %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!!
> 

I don't know how you get it to compile if it is in a file named 
sampl.java?  The file name and the class name must match.  Anyway your 
program isn't going to do anything without a window or frame to hold 
your components.  You should probably get rid of the CLASSPATH 
environment variable too, it is almost never needed.

-- 

Knute Johnson
email s/nospam/knute/

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#1504 — Re: Exception in thread "

From"tar" <tar@THRWHITE.remove-dii-this>
Date2011-04-27 15:33 +0000
SubjectRe: Exception in thread "
Message-ID<ymiodljypgp.fsf@sevak.isi.edu>
In reply to#1503
  To: comp.lang.java.gui
Knute Johnson <nospam@rabbitbrush.frazmtn.com> writes:

> xcrazy 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:
...
> > class swing_app {

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

> I don't know how you get it to compile if it is in a file named
> sampl.java?  The file name and the class name must match.

I think this is only true for public classes.  Non public classes can be
included in files with any name.  (Not that it's a good idea....)


-- 
Thomas A. Russ,  USC/Information Sciences Institute

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#1507 — Re: Exception in thread "

From"Knute Johnson" <knute.johnson@THRWHITE.remove-dii-this>
Date2011-04-27 15:33 +0000
SubjectRe: Exception in thread "
Message-ID<LaaWh.147749$Pi4.56725@newsfe14.lga>
In reply to#1504
  To: comp.lang.java.gui
Thomas A. Russ wrote:
> Knute Johnson <nospam@rabbitbrush.frazmtn.com> writes:
> 
>> xcrazy 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:
> ...
>>> class swing_app {
> 
>>> It compiles giving me a "sampl.class" file but when i type this
> 
>> I don't know how you get it to compile if it is in a file named
>> sampl.java?  The file name and the class name must match.
> 
> I think this is only true for public classes.  Non public classes can be
> included in files with any name.  (Not that it's a good idea....)
> 
> 

You're right, if the class is declared public it must match the name of 
the file.  If not public it will compile and it will produce class files 
for every class.  You can even put main() methods in each of the classes 
and run them.  I don't know what that does to package visibility.

-- 

Knute Johnson
email s/nospam/knute/

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web