+ 1

Run the java program

I am at the lesson on running first java program and have some question: I have already enter this in my notepad: public class ExampleProgram { public static void main(String[ ] args) { System.out.println("Hello World"); } } and name it as ExampleProgram.java. where should I save this file? I save it at desktop but it didn't function at command prompt. I have alsa tried to save at C:\Program Files\Java\jdk1.8.0_121\bin, but it still cannot function at command prompt. ( I type javac ExampleProgram.java at command prompt.) 2. How can I reply your answer at below if I have more problems? Thanks

14th Feb 2017, 4:41 AM
freedom
1 Answer
+ 3
You need to make sure you change directories (cd) in the command prompt to the directory that the ExampleProgram.java is in or supply the full path to the file at the prompt. To do this get the full path to where the file is located and type: cd "C:\fullPath\To\File" You should see the prompt change to the current directory. To check and make sure you're in the correct folder you can type: dir at the prompt. This will list all the files and folders in that directory. If you don't see your file then you need to cd again to the correct folder. Once you have done this you should be able to run the javac command (as long as you have the JDK installed and your path variable set correctly). You can just reply here in this thread.
14th Feb 2017, 4:59 AM
ChaoticDawg
ChaoticDawg - avatar