• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java cant find source file  RSS feed

 
Zach Williams
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Command Prompt gives me this error message when I try to compile any of my source files. Any ideas?
java-problem-2.png
[Thumbnail for java-problem-2.png]
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are your files relative to the Zach directory? Also, are you using packages?
 
Zach Williams
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My files are in the document folder under the "Zach" directory. I am not using any packages
 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zach Williams wrote:My files are in the document folder under the "Zach" directory. I am not using any packages


you should navigate to the directory where your Java source files are and then try to compile.
 
Zach Williams
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK that worked, I'm a little closer. I still cant get it to compile however.

Is there anyway to simplify this so I dont have to navigate to the directory each time?

Here is the screen shot of the error message i receive now
problem-3.png
[Thumbnail for problem-3.png]
 
Zach Williams
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fixed it so i dont get the error message, it was a simple mistake i made. Still need help simplifying the process though
 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are missing a closing parenthesis for System.out.println on line 14. Actually the compiler message clearly tells what you were missing or the reason for compilation failure.

You can provide the complete path to the Java source file while you are compiling. That way you need not navigate to the directory.

Edit: Sorry, This post got caught in the traffic and hence arrived late.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zach Williams wrote:Still need help simplifying the process though

How exactly do you want to simplify the process? Or do you just mean that you don't understand exactly what you are doing?

If you're not so familiar with the Windows command prompt, then maybe you should look for a basic tutorial about the command prompt. One important concept is that of the "current directory". When you run commands, they normally look at files in the current directory. The current directory is indicated by the prompt, as you can see. You change the current directory with the "cd" command.

When you compile a Java source file by typing javac MyProgam.java, then the Java compiler will look for the source file MyProgram.java in the current directory. If the file is not in the current directory, Javac will ofcourse complain that it can't find the file.
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Beware: screenshots are difficult to read.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!