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

compiler error

Saumyaraj Zala
Ranch Hand

Joined: Aug 06, 2012
Posts: 56

when i type javac classname.java an error comes that "javac is not recognized as an internal or external command,operable command or batch file"... whereas when i use Netbeans IDE,the program successfully runs...this means that my SDK is successfully installed so what is the problem?? please help...


Why do we fall? So that we can learn to pick ourselves up.
Vimal Kumar Venugopal
Ranch Hand

Joined: Aug 20, 2011
Posts: 43

Hi saumyaraj

The problem is Windows does not know where javac.exe is located. When you ask for it by typing a command starting with it, it checks the current folder, then each of the folders it knows to check, without any results. To fix this, the java folder must be one it checks.

To do this, first locate where java is installed, and where javac.exe is located. This will probably be something along the lines of C:\jdk\bin\ or C:\Program Files\Java\jdk\bin\ - I do not use Java personally so I'm not sure.

Second, go to Windows Explorer, right click My Computer, go to Properties, the Advanced tab, Environmental Variables. Under System variables, look for Path. Do NOT remove anything here, but instead at the END of "Variable value" add a semicolon (;) and a space, followed by the path you found earlier.

Hope this helps


"Value has a Value only if its value is valued!"
Saumyaraj Zala
Ranch Hand

Joined: Aug 06, 2012
Posts: 56

thankyou... it worked
Stevens Miller
Ranch Hand

Joined: Jul 26, 2012
Posts: 567
    
    4

saumyaraj,

Since you are using NetBeans, you may want to be sure that your javac command invokes the same compiler that NetBeans is using. I have noticed that it is pretty easy to end up with more than one compiler on one computer, especially when you are getting started.

To find out which one NetBeans is using, choose "Tools / Java Platforms" from the IDE menubar. The Java Platform Manager dialog box will appear. Near the top, it will have two text boxes, one labeled, "Platform Name," and the other labeled, "Platform Folder." Most likely, if you are just getting started, there will only be one platform on your computer ("platform" basically refers to a release of the Java Development Kit). That one platform will have the word "(Default)" next to it in the Platform Name text box. (If you have more than one, you probably want the default platform, though, if you are compiling a file you created in the NetBeans IDE editor, you want the one that came with the platform you are using to development the project that file is part of; if that makes no sense, just ignore it, as you probably only have one platform installed right now anyway.)

When you take Vimal's advice, the entry you want to add to the end of the PATH environment variable will be the full path listed in Platform Folder, but with "\bin" added to the end.

If you ever do install a new platform, even for an upgrade, be sure to change your PATH variable so it points to the directory with your new javac.exe file in it, not the old one. (Compiling with an old and a new compiler can create some maddening debugging problems, which some people refer to as the disease called "versionitis." You don't want to get versionitis, I assure you.)

Good luck.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compiler error