• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

setting the classpath

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've just downloaded jdk1.3.I want to know how to set the classpath so that i can compile program out side the directory.
 
Trailboss
Posts: 24091
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm moving this to Java in General (beginner)
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by jayari:
I've just downloaded jdk1.3.I want to know how to set the classpath so that i can compile program out side the directory.


Please execute the steps given below to check Java installation :

Step 1 :Check Autoexec.bat file
Edit Autoexec.bat file in your root directory. ie; open autoexec.bat in Notepad or any other text editor you feel comfortable with :
Check the PATH
Check for the sentence given in red colour in the PATH environment variable :
For example :
PATH=%PATH%;.........;c:\<jdk directory>\bin;
where <jdk directory> is the directory in which you have installed the JDK(Java Development Kit).
This is typically c:\jdk1.3 if you have not installed it elsewhere.
So you can check for :
PATH=%PATH%;........;c:\jdk1.3\bin;
Check the CLASSPATH
Check for the sentence given in red colour in the CLASSPATH environment variable :

For example :
set CLASSPATH=%CLASSPATH%;c:\<jdk directory>\lib;c:\<jdk directory>\lib\tools.jar;
where <jdk directory> is the directory in which you have installed the JDK(Java Development Kit).
This is typically c:\jdk1.3 if you have not installed it elsewhere.
So you can check for :
set CLASSPATH=%CLASSPATH%;........;c:\jdk1.3\lib;c:\jdk1.3\lib\tools.jar

P.S : If you do not find a CLASSPATH environment setting then you can add the following line to the autoexec.bat file IMMEDIATELY AFTER YOUR PATH environment setting.

set CLASSPATH=%CLASSPATH%;c:\<jdk directory>\lib;c:\<jdk directory>\lib\tools.jar;
where <jdk directory> is the directory in which you have installed the JDK(Java Development Kit) (eg. : c:\jdk1.3).

Step 2 : Running the test program.
Open Notepad
Type the java program given below :
public class Test{
public static void main(String[] args){
System.out.println(" Hello World");
}
}

Make sure the program is typed exactly as it is shown above. The Capitalization is very important. Otherwise you will not get the desired output.

Go to MS DOS prompt :
Create a directory called test in C:\ : by executing the following command(given in red).
C:\>md test
(alternatively you can create the directory from Windows Explorer by clicking File--->New ----->Folder Folder name : test)

Save the file as Test.java in the test directory (Remember it should be Test.java (with Capital T) and not test.java)
(Windows Explorer : click File---->New---->SaveAs : Test.java)

If you are not in MS DOS prompt, Go to DOS prompt now (Select MS DOS Prompt from Start---> Programs---MS-DOS Prompt)
Change to test directory :
C:\>cd test

Type the command given in red to compile your program:
C:\> javac Test.java (Remember not test.java)
(The computer will not display anything if everything is fine. If there is anything wrong it will display an error message)

If everything is ok and you are back in DOS Prompt ie.; C:\> , then type the command given in red to run the program :

C:\>java Test (Remember - do not type Test.java or test)

If everything is OK the computer will display the message :

Hello World

Your java compiler is set up. No more trouble... Enjoy

If you get error messages instead, then you have trouble: Call the expert.
Hi I had send this mail to somebody long ago. Hope this will be useful to you in checking your installation.
SJ
 
Sajan Joseph
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just refer to my previous reply to your message. If it looks cryptic, the reasons are
1. the red color is lost during uploading to java ranch.
2. All the tags '<'jdk directory '>' inside my original message have mysteriously diasappeared. HTTP has gobbled it up.
So where ever you find two backslashes(\) together (Eg : \\), pleade insert '<' jdk directory '>' while reading the message.
I hope this time HTTP will not swallow '<' & '>' :-)
SJ
reply
    Bookmark Topic Watch Topic
  • New Topic