• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javac cannot find Helloworld file

 
Titu Jack
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i type javac in command prompt i get right response. But when i try to compile my "helloworld.java"file , cmd dont find any java file.
Then these lines appears .
Javac:file not found:HelloWorld.java
usage:javac <options> <source files>
use -help for a list of possible options.
now what should i do. Please help me.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50182
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please don’t post a new question on an old thread. I have split your question into a new thread.

That error message confirms you have set your PATH correctly.

What files do you have in the current directory? Use the dir (or ls) command to check that you actually have the HelloWorld file in the correct directory.
Check you have spelt it correctly: Helloworld ≠ HelloWorld
Are you using javac or Javac?
Have you set a classpath? Find out what it is with echo %CLASSPATH% (Windows®) or echo $CLASSPATH (*nix).
If the classpath is not empty, try javac -cp . HelloWorld.java; if that works, you probably have a classpath problem.
Setting a system classpath usually does more harm than good. If you set it yourself, delete it. If nothing comes up, do nothing. If something comes up which you didn’t set (often caused by installing QuickTime), edit the classpath by adding .; (Windows®) or .: (*nix) at its beginning.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12196
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Titu Jack wrote:...when i try to compile my "helloworld.java"file , cmd dont find any java file.
Then these lines appears .
Javac:file not found:HelloWorld.java

Your Class name and the filename must be EXACTLY the same. If your file is really "helloworld.java", (all lower case) then the class name inside must be "helloworld" (again, all lowercase). There is a discrepancy somewhere, since the compiler is telling you it is looking for "HelloWorld.java"

Even when you type the javac command on Windows (which is case insensitive), it is passing that along to the java compiler, which is NOT case insensitive, so you still have to do it correctly.
 
Titu Jack
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As i have told before that i cannot compile my "HelloWorld.java" file. Cmd cant find this file. Now i want to know what i should set or write in both user and system environment variables. At the moment
You can assume that i have installed jdk properly in default way. You can also assume i have not set any user or system environment variables. Please show me what should i write in both user and system enviornment variables.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12196
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is kind of impossible for us to tell you what to put in your environment variables since we have no idea what your environment is.

if you 'cd' to the directory where your HelloWorld.java file is, and you are not getting a 'command not found' error, then it should work - assuming everything is what you tell us it is.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic