LiveWire Peer Support Network

Printable Version of Topic "Help with compiling a Java file?"

- LiveWire Teen Forums & College Forums (http://www.golivewire.com)
-- (http://www.golivewire.com/forums/support-technical.html)
--- Programming & Application Development (http://www.golivewire.com/forums/forum-211-s-0.html)
---- Help with compiling a Java file? (http://www.golivewire.com/forums/peer-yyatsst-support-a.html)


-- Posted by Majo at 4:24 pm on Sep. 6, 2008

I'm just starting my Programming for Info Tech I class and am already stuck. I did about half of my assignment in class, saved it to my flash drive, made sure it was on there, and then went back to my room.

I'm trying to work on it now but, well...it's empty... I open it and there's like...no coding in there...

So I started a new one and now I can't get it to compile. I can get it to compile in jGRASP but not in a DOS window which is what I'm supposed to do. Wha?...

*clearly a newbie*


-- Posted by HideOrSeek at 4:26 pm on Sep. 6, 2008

Gaaahh,
Under what extension did you save it?


-- Posted by Majo at 4:37 pm on Sep. 6, 2008

.java


-- Posted by matto at 12:49 am on Sep. 7, 2008

Quote: from Majo at 4:24 pm on Sep. 6, 2008


So I started a new one and now I can't get it to compile. I can get it to compile in jGRASP but not in a DOS window which is what I'm supposed to do. Wha?...

*clearly a newbie*


You need to tell us more.  What did you type?  What error was given?  What is the source code?  etc


-- Posted by Majo at 9:12 am on Sep. 7, 2008

I believe all I typed was:

Code:
public class ILoveJava
{
}


To compile it, I just typed:

Code:
javac ILoveJava.java


The error I was given was something to the extent of javac not being recognized as an internal or external command.


-- Posted by matto at 12:52 pm on Sep. 7, 2008

This is almost definitely caused by not having your java bin in your path.

Assuming windows because of the error you gave...
Go to wherever you installed java.  The default is C:\Program Files\Java\jdk1.6.0_07 if you're using the updated version at the time of this posting.  Make sure that this directory has a bin subdirectory, and that that bin subdirectory has java, javac, and all those other exe/bat files in there.

THEN add that bin directory to your PATH environment variable.
Start > Right click "My Computer" > Properties > Advanced Tab > Environment Variables > find PATH in the lower section and press Edit, and append C:\Program Files\Java\jdk1.6.0_07\bin to the end of that string (adjust as necessary).

NOW, open up cmd and if you type "echo %PATH%" the java bin should show up, and when you type java or javac it will be recognized as a command


www.golivewire.com