aspose file tools
The moose likes Beginning Java and the fly likes Java cant find source file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Java cant find source file" Watch "Java cant find source file" New topic
Author

Java cant find source file

Zach Williams
Greenhorn

Joined: Nov 07, 2010
Posts: 9
Command Prompt gives me this error message when I try to compile any of my source files. Any ideas?


[Thumbnail for java problem 2.png]

pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Where are your files relative to the Zach directory? Also, are you using packages?
Zach Williams
Greenhorn

Joined: Nov 07, 2010
Posts: 9
My files are in the document folder under the "Zach" directory. I am not using any packages
Mohamed Sanaulla
Bartender

Joined: Sep 08, 2007
Posts: 2926
    
  15

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.


Mohamed Sanaulla | My Blog
Zach Williams
Greenhorn

Joined: Nov 07, 2010
Posts: 9
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


[Thumbnail for problem 3.png]

Zach Williams
Greenhorn

Joined: Nov 07, 2010
Posts: 9
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

Joined: Sep 08, 2007
Posts: 2926
    
  15

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
Bartender

Joined: Aug 16, 2005
Posts: 12911
    
    3

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32654
    
    4
Beware: screenshots are difficult to read.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java cant find source file
 
Similar Threads
Need help with this code
Open Source - Global Calendar
Need XHTML validator.
Open source flex IDE?
Unable to launch JNLP application