Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HelloWorld will not compile  RSS feed

 
Aaron Barrett
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what happens in the command prompt window, see below:

C:\WINDOWS\system32>javac HelloWorld.java
javac: file not found: HelloWorld.java
Usage: javac <options> <source files>
use -help for a list of possible options

This is the location of jdk on my computer:

C:\Program Files\Java\jdk1.6.0_23\bin

HelloWorld.java is located here:

C:\Program Files\Java\HelloWorld

Please, tell me what I'm doing wrong. Thank you.

abarrettm31
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

First, you should create your own directory for your files. Do not use "Program Files\Java" because that will mix your files in with Java's installation. For example, you might create a directory called "myJava" under C (that is, C:\myJava) and put your own files there.

Next, to compile, use the cd (change directory) command so that your current directory is where your .java source file is located. For example, assuming you call your directory "myJava," then at the C prompt, type "cd myJava"...

C:\>cd myJava
C:\myJava>

Then, with myJava as your current directory, type "javac HelloWorld.java"...

C:\myJava>javac HelloWorld.java
C:\myJava>

(Note: The good news is that your system recognizes the "javac" command, so that means Java is installed and your path is updated correctly. )
 
Aaron Barrett
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!