Click to See Complete Forum and Search --> : Java Class not found


drummerboy195
08-31-2004, 12:50 PM
So I am starting to work through the examples in my Java textbook, I do the first one, it comes out fine. I try to do the second one, and I get an error


./<longfilename>.java:1: error: Can not found "javax/swing/JOptionPane" [JLS 7.5.2, 7.6]
./<longfilename>.java:1: error: Cannot find class "javax/swing/JOptionPane" [JLS 8]


I haven't been able to find an error like this and I have added /usr/java/j2sdk1.4.2_05/lib to my classpath.

Additionally, I tried to download Eclipse, and it gave me a similar error, complaning about not being able to find the necessary classes.

Any ideas?

JohnT
08-31-2004, 01:48 PM
I dont know if your familiar with the Sun tutorial......HERE (http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JOptionPane.html)

AlienNation
08-31-2004, 03:38 PM
Try clearing your classpath. Don't think you have to set it to gain access to the built in classes. I don't anyway :)

Your little app works just fine here.

fatTrav
08-31-2004, 04:09 PM
the file names and the class names must match EXACTLY.

travis@grendel 3:10PM travis % javac welcomeinmessagedialogbox.java
welcomeinmessagedialogbox.java:3: class WelcomeInMessageDialogBox is public, should be declared in a file named WelcomeInMessageDialogBox.java
public class WelcomeInMessageDialogBox {
^
1 error


I renamed the file to and changed the first line as it indicated, compiled it and then it ran perfect

you don't need anything added to your classpath to make swing applications. the only thing i have in my classpath is tomcat stuff for makin servlets. My PATH has the bin directory from my JDK install though.

drummerboy195
08-31-2004, 04:19 PM
I think that it is something wrong with my Java installation, because the file was originally capitalized as indicated, something in how i uploaded it changed it. The reason I think it has something to do with the installation is when I try to run IBM's Eclipse IDE, I get similar errors, concerning classes that cannot be found.

fatTrav
08-31-2004, 04:28 PM
My notes on installing the jdk

1 go to java.sun.com and download the linux bin file. i never let my distro install java cos it's easier if i do it myself.
2 make the bin file eXecutable
3 run the .bin file
4 move the new folder to /usr/local/java
5 set my shell's .rc file (.bashrc, .zshrc, whatever) to add the j2sdk's bin dir to my path.
6 I also set JAVA_HOME in my shell's rc file.
7 that's it.

The only reason I do this is because I prefer to keep all things java related in one locaton (tomcat being one) and I use the crypto add-ons among other things.

drummerboy195
09-02-2004, 03:34 PM
Thanks for all the help. I had followed your directions, but just as a note to anyone who comes behind me, if you have tried a million different installations of java, the symlinks in /usr/bin to the java components might not point to /usr/local/java/bin like they need to. That ended up being my problem. Thanks!