File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes setting up java environment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "setting up java environment" Watch "setting up java environment" New topic

setting up java environment

kamilla miesak
Ranch Hand

Joined: Mar 06, 2001
Posts: 30
I'm new to Java, and I've been trying to set up java SDK on my computer, so I can run programs from the command line. I've edited the execution path, and yet whenever I invoke java interpreter and compile a program - I'm getting a 'bad command' error. If I type 'java -version' - I do get all info about the java SDK, also typing 'javac' by itself gives me a list of options that come with the command. But when I type 'javac programName' the command is not recognized. How can I fix it?Thanks.
Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
this is how i did it.
i went to run typed in sysedit and found autoexec.bat
then i added this lines to it
set PATH = %PATH%;c:\jdk1.3\bin
my class pathlook like this your can be something else
set CLASSPATH = .;c:\jdk1.3\bin\;C:\jdk1.3\lib\servlet.jar;c:\myClass;%TOMCAT_HOME%\lib\servlet.jar
you will have to reboot your machine after.

Val SCJP <BR>going for SCJD
kamilla miesak
Ranch Hand

Joined: Mar 06, 2001
Posts: 30
I've tried it again, but it seems that for whatever the reason the autoexec.bat file does not keep new path settings eventhough I do save them. After rebooting, and typing 'path' at the c:\ I still see only old paths, with no java\bin directory. I also do not have classpath in autoexec.bat - should I add it? What it should be pointing to? I don't have servlet.jar command under bin folder. I've tried adding it up pointing to java\bin directory only, but that didn't work either.
Again, I'd appreciate all help. Thanks.
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
At work I have an environment where they won't allow me to mess with my autoexec.bat. So I have a p.bat file that I created to modify the path and add a classpath. When I escape to DOS I just type p and all is good for that session. For convenience I also use that file to move me (\cd) into the java directory where I work.
You can create a bat file by going to the DOS prompt and typing edit p.bat and you get a REALLY rough editor, but it works. Just add the statements like Val described.

"JavaRanch, where the deer and the Certified play" - David O'Meara
Siva Prasad
Ranch Hand

Joined: Feb 22, 2001
Posts: 104

Hi Kamillia
You have to keep onething in your mind whenever you try to add or modify anything in autoexec.bat
i.e. it doesnot take the changes you made when you try to save that file. (Its a security issue in windows)
All what you have to do is..
rename the existing autoexec.bat and rename it as auto.tmp
and now edit this tmp file and add or modify PATH and CLASSPATH.
now rename this autoexec.tmp as autoexec.bat.
Reboot your PC and this time it would work.
If you still have problems then let us know.
onemore thing...
when u compile a java program do u use the fullname of the file?
e.g. javac or not?
if u say javac sample compiler gives an error.

[This message has been edited by Siva Prasad (edited March 07, 2001).]
kamilla miesak
Ranch Hand

Joined: Mar 06, 2001
Posts: 30
Guys, renaming the file finally worked! Thanks!
I agree. Here's the link:
subject: setting up java environment
jQuery in Action, 3rd edition