Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Path Setting Basics 1

Status
Not open for further replies.

sap

Technical User
Aug 20, 2001
37
0
0
IN
I've jdk 1.3.1 installed on my pc with windows 2000 server as o/s. All the java source code are stored in D:/javasource folder where as,JDK is installed in c:/ drive. and i'm using KAWA as editor to write
source code.
system variable is set as "JAVAHOME" c:/jdk1_3_1/bin

with kawa there is absolutely no problem but, when i try to compile or run the program at COMMAND PROMPT, system could not locate the .java or .class file though full path is given as
c:/>jdk1_3_1 javac d:/javasource/ex1.java

I feel that some more setting for mapping the source folder is reqd.
but don't 've info. to go about. Pls help.

-- sap
 
I may be mistaken, but the java applications are all contained within the BIN folder library of your java library so really your command may have to look something like this:

c:/>jdk1_3_1/bin javac d:/javasource/ex1.java

phil
[hammer]
 
of course you could just add c:/>jdk1_3_1/bin to your system path variable and that would allow you to just type javac
 
Taking that suggestion one step further, I always keep a .bat file around to do java work on the command line. It starts doskey, includes the jdk/bin directory in the path, and changes me to the root of my java source folders.

Code:
@echo off
PATH=[your path here with jdk/bin]
doskey
cd [your java source folder]
 
If you just write this to the command prompt (since your jdk is in the folder c:\jdk1_3_1\bin)

c:/>path=c:\jdk1_3_1\bin

which ever java file you compile and then run will be compiled no matter where your source code folder is. But this will only work once for each dos-prompt session. Like segmantationfalut said, you can also put it in a batch file and this will ease you off the tension of changing folders.
Try it out.

take care
 
as you have stored ur java source files in d drive in a folder named 'javasource' just follow the following steps to set the path

just do the following:

d:/>javasource/path=c:/jdk1_3_1/bin

this will set the path and u will see this on the prompt:
d:/>javasource/

now just compile ur java file by typing the command used for compiling. so easy!
 
pipk,
You are just right.It worked. But now the problem is i can't run the program after compiling it.
when i type
c:/>jdk1.3.1>bin> java d:/javasource/ex1.class
it gives an error : class def. not found.

can you guide me plz.
 
I think it may be because you are referencing the class with the .class extension - just try typing

c:/>jdk1.3.1>bin>java d:/javasource/ex1

and see if that works, also note that the class name should appear exactly as it is (I am pretty sure it is case sensitive, so if your class is actually called "EX1" rather than "ex1" then the java command will not recognise it).

hope it works

[hammer]
 
thanX!!! pipk,
My prob. is solved.
.class extn. is not reqd.
 
for excecuting a class file you can use class path variable:

d:/javasource>java -classpath d:/jdk1.3.1/bin ex1


in this wasy you need not be in the jdk/bin folder when you want to run a java program






 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top