I am trying to set up my laptop for a java course I am taking. Presumably, all I have to do is download the SDK, and change a few environmental variables, and then I should be able to run my first Hello World program.
I found that it is not that easy. I put the SDK on the C: drive. Then I went to Control Panel, SYSTEM, ADVANCED, ENVIRONMENTAL VARIABLES. I changed the CLASSPATH to where my classes were, and the PATH so it would look in the bin of the SDK. Well, I have program that I copied from the book called Address and I know it works on the machines at school. On my machine, it compiles when I use:
But when I try to run it using:
I get the error message:
Exception in thread "main" java.lang.NoclassDefFoundError Address/class
My instructor said that the problem was in the CLASSPATH variable I was using. I didn’t think so, but I changed CLASSPATH to ‘c:\j’. I then put Address.class in the new j folder and got the same result.
One thing I noticed that is strange is that the PATH “environmental variables for user1“ dialog box displays :
which is how I set it up. However, when I go the cmd prompt and type PATH, I get the following:
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Adaptec Shared\System;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;c:\j2sdk1.4.2_05\bin;C:\JDK1.2.1\BIN;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Adaptec Shared\System;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\
When I saw this, I thought, “ Why would duplicate paths be there and how do I get rid of them?” That is puzzling enough, but that doesn’t answer the question, “Why won’t my Java programs run?”
Bah! I knew I should have stuck to VB.
Do you have any idea how I can fix the Java problem?
How do I fix the PATH problem?
Thanks for listening.