IntelliJ Java IDE
The moose likes Beginning Java and the fly likes Can't find class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Can Watch "Can New topic
Author

Can't find class

Amanda Weber
Greenhorn

Joined: Nov 20, 2002
Posts: 28
For some reason I had to uninstall/reinstall java on my P.C. - a Windows 98 operating system. It was working fine before, but I installed a different program and I didn't want the Java to be effected by it. I didn't change any of the paths/classpaths. Now the compiler works, and everything compiles fine but when I try running my application I get the message Can't find class *****. What should I do?
Monty Ireland
Ranch Hand

Joined: Oct 03, 2000
Posts: 161
I have a few questions:
1. what ver of win98
2. what ver of java
3. what is your CLASSPATH
4. what is your PATH
A guess without the above information would be that you are missing. The CLASSPATH current directory reference of ;.;
We are all here to help...
[ November 21, 2002: Message edited by: Monty Ireland ]

Multi Platform Database Developer & DBA on E.S.T.
Amanda Weber
Greenhorn

Joined: Nov 20, 2002
Posts: 28
I have window 98 second edition. I am not sure what version. Java 1.2, the path is set to c:\jdk1\bin\ among other things and the classpath is set to c:\jdk1.2\bin;.;
Monty Ireland
Ranch Hand

Joined: Oct 03, 2000
Posts: 161
I am getting win2000 and win98 confused.
From a dos prompt. Use the set cmd to verify
you PATH and CLASSPATH settings.
I have a few ideas to try...
1. set your CLASSPATH to only ibnclude"."
2. if that fails set you CLASSPATH to include RT.JAR (depending on what version of java you have)
If the above fail... let me know and i will send
you from home tonight my win98 PATH and CLASSPATH settings.
hope this helps...
Amanda Weber
Greenhorn

Joined: Nov 20, 2002
Posts: 28
The path does include the classpath. I am not sure about the JAR file. The classpath includes the current directory "."
[ November 21, 2002: Message edited by: Amanda Weber ]
Amanda Weber
Greenhorn

Joined: Nov 20, 2002
Posts: 28
I am getting more and more confused with Java
I did some more testing. I was able to compile and run a simple program that has only a main method that has a System.out.println("test"); and that works fine. When I try and add any of java's Classes from any package I get the message "Can't find class Test".
What am I suppose to do to get this to work?!?!?!?
[ November 21, 2002: Message edited by: Amanda Weber ]
Monty Ireland
Ranch Hand

Joined: Oct 03, 2000
Posts: 161
sorry i did not get back to you last night.
for i had to deal with the kids.
i know the problems you are having.
I know exactly how you feel.
please send the following information.
1. version of java - c:\java -version
2. copy and paste you autoexec.bat file
3. from a dos prompt get you PATH and CLASSPATH
please send me the above...
and we shall fix your problem over the weekend
Amanda Weber
Greenhorn

Joined: Nov 20, 2002
Posts: 28
the version of java is:
1.1.7.31.o
the autoexec is:
@ECHO OFF
REM [Header]
DOSKEY
REM [CD-ROM Drive]
REM [Miscellaneous]
REM [Display]
REM [Sound, MIDI, or Video Capture Card]
REM [Mouse]
rem PATH=C:\PROGRA~1\THINKPAD\HIBERUTL;%PATH%;
rem PATH C:\PROGRA~1\THINKPAD\UTILIT~1;%PATH%;
REM The following line creates the hibernation file.
rem if not exist C:\save2dsk.bin C:\PROGRA~1\THINKPAD\HIBERUTL\phdisk /c /f rem <C:\PROGRA~1\THINKPAD\HIBERUTL\yes
path = C:\jdk1.2\bin;.;"%PATH%"
set path = C:\jdk1.2\bin;.;"%PATH%"
set path=C:\oraforms\jdk\bin;"C:\ProgramFiles\Oracle\jre\1.1.7\bin";"%path%";
set Path=C:\orawin95\bin;"%Path%"
PATH C:\oraforms\bin;"%PATH%"
set classpath = C:\jdk1.2\bin;.;
a dos prompt set:
PATH=C:\jdk1.2\bin;.;"C:\JDK1.2\BIN;.;C:\WINDOWS;C:\WINDOWS;C:\WINDOWS\COMMAND"
PATH = C:\ORAFORMS\BIN;C:\ORAWIN95\BIN;C:\ORAFORMS\JKD\BIN;C ROGRAMFILES\ORACLE\JRE\1.1.7\BIN;C:\JDK1.2\BIN;.;C:\WINDOWS;C:\WINDOWS;C:\COMMAND;
CLASSPATH=C:\JDK1.2;BIN;.;
Thanx so much!!
[ November 23, 2002: Message edited by: Amanda Weber ]
Philip Shanks
Ranch Hand

Joined: Oct 15, 2002
Posts: 187
I recommend that you NOT have any CLASSPATH environment variable set in Windows. This is likely the source of your problems. The only adjustments that I make to run Java are as follows:
  • Set the JAVA_HOME variable to point to the directory where your JDK is installed, for example, "C:\j2sdk1.4.1_01"
  • Make sure that the Java bin directory ("%JAVA_HOME%\bin") is listed in your PATH variable.

  • I believe that if a CLASSPATH is explicitly named, then the Java environment will limit itself to only what is listed in that CLASSPATH.
    PCS
    DISCLAIMER:
    I have in the past been wrong, and there is a finite likelihood of this being a recurrance.
    [ November 22, 2002: Message edited by: Philip Shanks ]

    Philip Shanks, SCJP<br />Castro Valley, CA<br />--<br />My boss never outsources or has lay-offs, and He's always hiring. I work for Jesus! Prepare your resume!
    Amanda Weber
    Greenhorn

    Joined: Nov 20, 2002
    Posts: 28
    I tried deleting the classpath all together. -- That did not help at all. I tried to set JAVA_HOME to = jdk1.2, I THINK I did that correctly, but it still gives me the same error: Can't find Class Test - this happens with any java file that uses any of Java core classes.
    It is O.K., Philip - I am begining to think that my computer is jinxed!! :roll:
    Does anyone else have any advice for me?!?!?!
    James Chegwidden
    Author
    Ranch Hand

    Joined: Oct 06, 2002
    Posts: 201
    We had some classpath problems with W2k at school. We were still able to get java to compile/work but had to do some "round about" ways to do it.
    At home I have had no problems with the class path. I do not touch my environmental variables. I use the path command at the dos prompt. May not be the best way but it works.


    Mr. C<br /> <br />Author and Instructor<br />My book:<br /><a href="http://www.aw-bc.com/catalog/academic/product/0,1144,1576761614,00.html" target="_blank" rel="nofollow">http://www.aw-bc.com/catalog/academic/product/0,1144,1576761614,00.html</a>
    Marilyn de Queiroz
    Sheriff

    Joined: Jul 22, 2000
    Posts: 9001
    PATH=C:\jdk1.2\bin;.;"C:\JDK1.2\BIN;.;C:\WINDOWS;C:\WINDOWS;C:\WINDOWS\COMMAND"
    PATH = C:\ORAFORMS\BIN;C:\ORAWIN95\BIN;C:\ORAFORMS\JKD\BIN;C:\PROGRAMFILES\ORACLE\JRE\1.1.7\BIN;C:\JDK1.2\BIN;.;C:\WINDOWS;C:\WINDOWS;C:\COMMAND;
    CLASSPATH=C:\JDK1.2;BIN;.;

    I notice you are mixing jdk1.2 with JRE 1.1.7 -- This may cause you some problems since the JRE 1.1.7 may not be able to read some of the 1.2 compiled stuff (which might give you a ClassNotFoundException). Any way to avoid this?

    Also your classpath should point to the subdirectory containing your compiled *.class files, not the jdk1.2\bin subdir.
    [ November 23, 2002: Message edited by: Marilyn de Queiroz ]

    JavaBeginnersFaq
    "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
    Mark Buntain
    Greenhorn

    Joined: Nov 23, 2002
    Posts: 3
    A couple important things to check:
    if you are compiling from the Windows Command Prompt C:\>, the PATH command must be set so that it includes the directory path that contains your compiler programs. (since you say the compiling works OK, it would seem that this functional.)
    Once you have the compiled abcdef.class files, determine the directory path of their location. Java must know this CLASSPATH so that the JAVA Virtual Machine can locate your .class files.
    Perhaps a simple analogy would help: In my house(aka your PC)we have two systems, my wife and I(aka Windows and Java) We each put our socks in different drawers (aka directories). As long as each system puts its socks consistently in the same place, no problem. If my wife wants to find my socks, she would need to have directions to find them. Likewise with the file system, each individual system (Word, Java, DOS, Excel, Netscape, etc.) needs the proper path to locate its files. (Now I've figured out for myself why the hell I can't find my socks!!My wife never tells me where she puts 'em, (IF she puts them!))
    Hope this wasn't too insultingly simple. I've been there, and I know how utterly nerve wracking it can be. Keep us posted.
    Amanda Weber
    Greenhorn

    Joined: Nov 20, 2002
    Posts: 28
    Great News Everyone!
    I had some Divine Help from the One Above and I figured it out. Marilyn, Thank you - that was the basic problem. The program I refered to in the very first post installed it's own version of Java, which caused all the confusion.
    Now everything seems to be working
    Thank You!!
    [ November 23, 2002: Message edited by: Amanda Weber ]
    Monty Ireland
    Ranch Hand

    Joined: Oct 03, 2000
    Posts: 161
    better lat than never...
    i agree....
     
    IntelliJ Java IDE
     
    subject: Can't find class
     
    Threads others viewed
    packages
    Why private isnt private, story about Inner Class.
    Access of classes across packages?
    JBuilder help
    How to get Eclipse working with my bunch of .java and .class files?
    developer file tools