Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
When i go to compile a java program using the import javax.swing.*; i get a JFrame class not found!! i have the path set to usr/local/j2sdk1.4.1_02/bin: but in that dir isnt there supposed to be javax*? i see java*, javac* javadoc* etc. every program i write compiles until i import the javax.swing.*;

You seem to be missing some knowledge of te fundamentals of Java programming. The files in /usr/local/j2sdk.1.4.1_02/bin are the utilities (tools) included as part of the Java 2 SDK - i.e., the compiler, the interpreter, the javadoc tool, etc...
javax.swing.* is an API package that comes with the Java 2 platform. It contains many classes. There is no javax file in your bin directory. All standard API classes are included in the file rt.jar, which will be somewhere under the jre directory. You do not need them in your path. You do not need to extract them from the jar file. You *do* need to fix your classpath, or your java installation. If there is a system variable named CLASSPATH, clear it and your java program should compile. If that doesn't fix it, make sure your syntax and spelling are correct in your import statments. If it still isn't fixed, your Java installation is probably corrupted.
Jonathan

I just installed the j2sdk1.4.2_01, made the export PATH=/home/joe/j2sdk1.4.2_01/bin:${PATH}
on another computer it is installed j2sdk1.4.1_02, directory structure same path and compiles and runs fine
I echo CLASSPATH and get a blank line, so there must be no classpath set.
this is the error i am getting on compile:
SwingApplication.java:44: error:Variable "UIManager" is not defined in current context
SwingApplication.java:48: error:Cannot find class "JFrame" [JLS 8]

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |