Compiling java in cmd?

DrunkPotHead

Diabloii.Net Member
Compiling java in cmd?

I know there's a certain program or something that allows you to compile java programs in cmd using javac filename.java

It also lets you run them using java filename

Same as in unix kind of.
I was wondering, what do i have to download to be able to do this in cmd? Any know?
 

Cygnus434

Diabloii.Net Member
Okay, I'm going to assume you are using Windows XP first of all......if not, just let me know......here it goes:

Right click on My Computer, goto properties > click Advanced > click Environment Variables at the bottom > Under System Variables Select "PATH" and click edit.

Add a ; (semi-colon) to the end of the string there and then add the full path to your javac/java executables (e.g: C:\java\ if they are in C:\java). I can't remember the default directory, as I haven't installed java since my last format.....

But that should do it. If it doesnt work, try rebooting and seeing if it works......
 

DrunkPotHead

Diabloii.Net Member
So windows XP (yes, that's what im using) automatically has a java compiler installed on it?

If so, i have no clue where it is, i don't have a directory named C:\java\...
If not, where do i download it?
 

220683

Diabloii.Net Member
http://wwws.sun.com/software/download/app_dev.html

you can download it at Sun, scroll all the way down to the SDK section. The standard would be fine. What you want to do is sort like using gcc to compile under unix right? So after you got everything installed, there should be a compiler somewhere under /bin subdirectory (haven't used java for a while). Should be fairly easy to figure out...Good luck.
 

DrunkPotHead

Diabloii.Net Member
Shade said:
In which case try 'javac filename.java', then run using 'java filename'.
I tried that, and it gave me "javac unknown command" error or something along that line.

I finally figured it out. I am supposed to put that .java file into the same directory where all the java-type exe files are like java.exe, javac.exe, etc
 

Cygnus434

Diabloii.Net Member
DrunkPotHead said:
I finally figured it out. I am supposed to put that .java file into the same directory where all the java-type exe files are like java.exe, javac.exe, etc
No, if you add the location of where those executables are to the path, then it should work.

I just installed the 1.5 beta sdk.......the javac/java executables were in "C:\Program Files\Java\j2sdk1.5.0\bin"

I just added C:\Program Files\Java\j2sdk1.5.0\bin to my path under environment variables and it works perfect.
 
Top