1. I had JDK 1.4.2 earlier and have created a lot of examples but when I try to run them in JDK 1.5.0, I get errors at many places due to revised classes. Now, I am wondering how to make my older java files work???
2. Is it always necessary to set the classpath whenever we install JDK anew? Because, when I installed jdk 1.5.0, most older programs compile with errors rather not giving classNotFoundException.
If I have to set normally a classpath, then should I point to *somefile.jar* at install-dir/jre/lib.
I know we can set classpath using set classpath=%classpath%;new_path
Hi, I do not think that you would run into lots of errors that were using JDK1.4.2 and now you are planning to use JDK 1.5. I think the new environment that you have setup is not picking up some classes or third party libraries that you might have used earlier. When new versions are released people also do care about backward compatibility, hence at best you might have warnings for using deprecated APIs but it suddenly would not vanish from the JDK to give you any severe compilation errors. Classpath has always been a very touchy issue. It would help if you put some error logs to show exactly what troubles you have run into. You can see your classpath from cmd (I assume you are a windows user) by typing either echo %CLASSPATH% or by typing SET on the command prompt. In the latter case you would ssee values for all environment variables that are set not just the classpath. Hope this helps -Aviroop
Originally posted by Raghavan Chockalingam: I know we can set classpath using set classpath=%classpath%;new_path
but how do I see the current class path in cmd?
If you want to see all your environment variables, type SET at the Windows command line. If you just want to see one of them, say CLASSPATH, type SET CLASSPATH at the command line. To find out how to use a particular command in detail, say SET, type HELP SET at the command line.
Joined: Dec 20, 2005
There were discrepancies with the classes in the Swing package. It is refined more now. Anyway, thank you guys for your answers.
1. Can you confirm that I should set classpath to install/jre/bin/rt.jar? 2. Is it rt.jar to which I have to set the classpath? 3. Do we have to set classpath deliberately everytime when we install any JD Kit?
1. Can you confirm that I should set classpath to install/jre/bin/rt.jar? 2. Is it rt.jar to which I have to set the classpath?
No, you do not need to set the classpath to install/jre/bin/rt.jar. You do not need to include rt.jar into the classpath at all.
3. Do we have to set classpath deliberately everytime when we install any JD Kit?
No. If you do not set the classpath at all, Java will look for classes in the current directory (i.e., the directory from which you type "java ..." in the command prompt). You do not need to include any classes from the JRE into your classpath explicitly.
Thanks for replying jesper... 1. let's say that i have java files in c:/java I have the jdk installed in j:/jdk1.5.0 Now how does the system know that classes are at J:/jdk1.5.0/jre/lib? Normally classpath would have a dot(.) representing to look for classes from the current directory,,,if they don't find classes there where will they go???
2. I see two java and javac exe files in jdk-install-dir/bin jdk-install-dir/jre/bin
Why there are two sets and what is the difference between them?
If you have installed the JDK correctly, you have put J:\jdk1.5.0\bin in the PATH (note, that's not the same as CLASSPATH). (See the JDK installation instructions). If you did this, Windows knows that it can find javac.exe and java.exe in J:\jdk1.5.0\bin.
javac.exe and java.exe are smart enough to find the standard libraries somewhere under J:\jdk1.5.0, they can see the exe files themselves are there in the bin directory.
In the jdk-install-dir/jre/bin directory, there's only java.exe (not javac.exe). I don't know exactly why it's there.
If you're still wondering how Java finds its classes, read the following, it contains all the details: How Classes are Found
Joined: Dec 20, 2005
Now, I come to know why only java.exe at the install-dir/jre/bin because it's only the JRE package used to run compiled class files... as we could remember SUN gives two packages jdk and jre or jre only. JDK already has java and javac with itself but JRE has java.exe only.
subject: How to run Java programs made in older versions