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

Having Trouble Compiling

Benjamin Chau
Ranch Hand

Joined: Oct 05, 2008
Posts: 49
Hello All,

I installed the Java software onto my computer, along with the NetBeans IDE. I then tried to set the environment variable correctly (though still haveing problems with that). Now when I use the Command Prompt to compile the program I still get an error message. Any suggestions?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39885
    
  28
Leave NetBeans alone until you are used to using the command line. IDES hide the use of command-line arguments, and also there is enough to learn with Java alone, without having to learn the IDE too.
Learn the IDE later.

What are you trying to compile and what sort of error are you getting?
Have you found the Java Tutorials? There is a page about "common problems."
Please tell us what the error messages say; we usually recognise them, but can't help without that information.
Benjamin Chau
Ranch Hand

Joined: Oct 05, 2008
Posts: 49
Campbell,

I'm not concerned about the IDE but would definitely like to the program to compile and run with Command Prompt at least. Here's the message I get when I run Javac on a program:

'Javac' is not recognized as an internal or external command, operable program or batch file.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39885
    
  28
That tells me two things:
  • 1: You are using Windows; Linux gives a different error message.
  • 2: You haven't got your PATH set up correctly.
  • Everybody gets that problem. That is why it is the first problem quoted in the "problems" link I sent you. Follow the instructions in that, and follow the link to "setting the PATH permanently." Make sure to set it permanently, and don't believe them when they say it's "optional."
    It will be a lot easier if you remember where you installed Java; that will be the same directory as you told NetBeans when it asked about JAVA_HOME or similar. The PATH entry starts with the drive letter (usually C) and ends with bin.

    You don't need lots in your CLASSPATH, but you might as well check it when you set the PATH. It should have .; or ;. or ;.; in it somewhere, where the . means "current directory." You usually have to change your PATH and don't usually have to change your CLASSPATH.
    [edit]Add this link which tells you about setting the PATH.[/edit]
    [ November 05, 2008: Message edited by: Campbell Ritchie ]
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 39885
        
      28
    By the way, it's not Javac but javac. I did try Javac on my Windows box and didn't get an error, so I don't think it is the capital J causing the problems.
    Rob Spoor
    Sheriff

    Joined: Oct 27, 2005
    Posts: 19762
        
      20

    Windows is case insensitive so you can even call it jAVaC if you like
    The file also doesn't have to match the actual case.

    Now when running the application, the class name's case DOES matter. But then again, only the class name; you can write JaVa if you like.

    Note that Linux / Unix is 100% case sensitive.


    SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
    How To Ask Questions How To Answer Questions
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Having Trouble Compiling