*
The moose likes Beginning Java and the fly likes Compiling prob Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compiling prob" Watch "Compiling prob" New topic
Author

Compiling prob

j patrick
Greenhorn

Joined: May 02, 2008
Posts: 11
Just cant compile for some reason, path seems ok
PATH=C:\Windows\system32;......;C:\Program Files\java\jdk1.6.0_10\bin

, but get this

C:\Users\Steve> Javac Hello.java

Javac: file not found: Hello.java
Usage: javac <options><source files>
use -help for a list of possible solutions

just got new computer, maybe its administartor probs?

This is driving me up the wall lol, any help would be much appreciated

cheers
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

I think your PATH is okay, because otherwise you would get a message "javac is not recognized..."

Are you certain that your current directory contains that file (Hello.java)? Try typing the "dir" command for a list of what's in the directory.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38509
    
  23
Your PATH appears to be correct because otherwise it would give an error message starting "javac is not recognized . . ."
Which directory have you got your Hello.java file in? I presume you are in the same directory; on Windows you can verify its presence with "dir" and on *nix you would use "ls".

[diversion]So far, so good; I have told you more or less the same as Marc, who seems to have beaten me by a few seconds. And I see he has passed 10000. Congratulations, Marc.[/diversion]

Once you have found your Hello.java file, try inserting " -cp . " between "javac" and "Hello.java" (minus the quotes). Several people have posted in the last few weeks with the problem of not having a CLASSPATH set.
You can set a CLASSPATH for the lifetime of your present terminal window by writing something like set classpath=.;%CLASSPATH% See this link.

You will see all sorts of things on the net telling you to put this that and the other in your system CLASSPATH; there is only one thing you really need on Windows, which is a dot. It can appear as . or .; or ;. or ;.; and it doesn't seem to matter if it appears twice. You can set up your CLASSPATH by a similar process to setting the PATH; if there is no CLASSPATH at all, you can create one by writing CLASSPATH (it is probably not case-sensitive) in the box and . in the next box.
Close your command line window; the CLASSPATH will only work in a new terminal.
I usually use Linux, where it seems to work with no CLASSPATH set at all.
j patrick
Greenhorn

Joined: May 02, 2008
Posts: 11
ahhh i got it, cheers, i was having problems saving files in the right directory, if that makes sense. The smallest problems can have you pulling your hair out.

Much appreciated!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38509
    
  23
Originally posted by j patrick:
ahhh i got it, cheers . . . The smallest problems can have you pulling your hair out.

Much appreciated!


You're welcome ( ). And I remember spending weeks failing to get anything to compile when I first started. I know exactly how it feels.

And you have obviously now got your CLASSPATH sorted out.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Campbell Ritchie:
...I see he has passed 10000. Congratulations, Marc...

Thanks! Time for a nap.
 
Consider Paul's rocket mass heater.
 
subject: Compiling prob