File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes how to execute simple swing program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to execute simple swing program" Watch "how to execute simple swing program" New topic
Author

how to execute simple swing program

Robin Clark
Ranch Hand

Joined: Dec 17, 2003
Posts: 81
I am able to compile a very simple Swing example:



But when I try to run it, I get the following error:



How do I fix this problem?
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
This sounds like a classpath issue. If you do a search for classpath here you should find quite a bit.
Robin Clark
Ranch Hand

Joined: Dec 17, 2003
Posts: 81
Yes, I agree. Here is what my classpath is set to:



The very first entry in my classpath is the current directory which is where I am trying to execute the program. So I do not see the problem...
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
And there is a SimpleTableDemo.class file in the download directory?
Robin Clark
Ranch Hand

Joined: Dec 17, 2003
Posts: 81
Yes, the SimpleTableDemo.class file is in c:\download.

The message indicates to me that it is not able to find the JFrame.setDefaultLookAndFeelDecorated(true) method. I think that the JFrame class is implemented in jre\lib\rt.jar (based upon a google search). However I am having problems looking in rt.jar. I think that I should be able to say jar -t rt.jar in order to see all of the classes that are implemented in the file. But when I do this the screen just hangs and I don't get any output.

I've tried adding c:\j2sdk1.4.2_7\jre\lib\rt.jar to my classpath, but this doesn't see to remedy the situation.

Here is the current output:


[ March 04, 2005: Message edited by: Robin Clark ]
Robin Clark
Ranch Hand

Joined: Dec 17, 2003
Posts: 81
Well, finally I am able to get the simple program to run successfully. This is what my classpath looks like:

Robin Clark
Ranch Hand

Joined: Dec 17, 2003
Posts: 81
In my older cmd.exe window I still couldn't get the program to execute. I determined what I needed to do to fix the problem was to change my path environment variable to put the c:\j2sdk1.4.2_07\bin at the very beginning of the path. I have NO idea why this fixed the problem. Can someone explain this to me?

Path after I moved c:\j2sdk1.4.2_07\bin to the beginning. Right after I did this the SimpleTableDemo program would execute successfully.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to execute simple swing program