Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm in the process of making my HelloWorld.java program but have run into a problem in the cmd. Whenever i write "javac HelloWorld.java" I get this error message:

javac: file not found: HelloWorld.java

Usage: javac
use -help for a list of possible options

I have triple checked that my program is in the correct folder, I have changed "Path" to the correct folder. I have used the default Windows Notepad to write the Java code.

share|improve this question

migrated from gamedev.stackexchange.com Jul 25 '11 at 13:39

This question came from our site for professional and independent game developers.

closed as not a real question by Sathya Oct 20 '11 at 9:21

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
that's not the problem of javac, it's most likely the problem with your path variable. –  Ali.S Jul 25 '11 at 10:38
    
Guaranteed that it's a problem with PATH not being set. Find the /bin directory for your java installation and add it to your environment path. –  Patrick Hughes Jul 25 '11 at 12:57
    
windows button+Pause break ->Advanced-> Environment variables. Nice shortcut to know =) –  Nailer Jul 25 '11 at 13:04
    
What OS is this for? –  thegrinner Jul 25 '11 at 17:59
    
@thegrinner Windows, obviously: > I have used the default Windows Notepad to write the Java code. –  slhck Jul 25 '11 at 19:46

3 Answers 3

Try:

javac ./HelloWorld.java

If not, make sure you're spelling the source file correctly and that it is present in you current working directory.

share|improve this answer

I would first check that you saved the Java program as .java extension. In Windows Notepad, you do this by selecting File -> Save As and under File name, change .txt to .java

I would also recommend you Notepad++ which is a very good source code editor for quick code writting and for beginners.

share|improve this answer

PATH has nothing to do with finding .java files.

PATH is just to do with executable files.. (and possibly others if adding certain extensions to PATHEXT, but that use case isn't so relevant to your problem, and anyhow PATH wouldn't have anything to do with specifying a file as a parameter to a program, which is what you were expecting)

You have to either go to the path where the file is and do javac helloworld.java

 c:\myprojects>javac helloworld.java

Or, you specify the path of the java file when you run javac.

 javac c:\myprojects\helloworld.java

There is such a thing as CLASSPATH, but that is for .class files and java.exe Not for javac and .java files.

One use of PATH would be for finding javac.exe and java.exe (Running them from wherever you are) , but not for locating .java files. It looks like you already have that sorted, certainly for javac.exe anyway. Your PATH as it is for this.

share|improve this answer