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

can't start compiler

Michael Weber
Greenhorn

Joined: May 11, 2005
Posts: 15
Hi everyone,
I just installed jdk and jre 1.5, but I can't seem to compile anything. My cmd starts with C:\Java, and when I type %javac MyWorldApp I get the following: "%javac is not recognized as an internal or external command, operable program or batch file."

This happens no mather which application I try to compile. I would appreciate your guys' help on this one. Thanks in advance.
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
Whats with the percentage sign before the javac? Are you actually typing that in? You shouldnt be.
Michael Weber
Greenhorn

Joined: May 11, 2005
Posts: 15
I don't type in the percentage sign, and still the same problem occurs. Thanks for replying though.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
have you followed the installation instructions and added the proper things to your system settings to get the system path to include the jdk/bin directory?


42
Arjun K
Ranch Hand

Joined: Mar 09, 2005
Posts: 39
If your jdk is copied in c:\jdk1.5 directory then try the one below.
c:\jdk1.5\bin\javac yourApp.java
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
I didn't mention changing the PATH environmental variable because AFAIK on recent JDK installations this doesn't need to be done manually. At least on Windows 2000/XP.
Michael Weber
Greenhorn

Joined: May 11, 2005
Posts: 15
Originally posted by Arjun K:
If your jdk is copied in c:\jdk1.5 directory then try the one below.
c:\jdk1.5\bin\javac yourApp.java


My JDK is placed at C:\Java\jdk1.5.0_03
Even though I tried what you suggested, I get the message "The System cannot find the path specified."

The path I've put in system is "%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Java\jdk1.5.0_03"

I tried many things so far, but none has worked
Thanks for your comments guys.


Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
Check inside the C:\Java\jdk1.5.0_03 directory. There should be a bin directory in there. Inside the bin directory should be javac.exe
Michael Weber
Greenhorn

Joined: May 11, 2005
Posts: 15
Originally posted by Stuart Gray:
Check inside the C:\Java\jdk1.5.0_03 directory. There should be a bin directory in there. Inside the bin directory should be javac.exe


I checked it before as well. Yes, it's there. What do I do with it? When I start it, nothing really happens. Thanks.
Marcus Laubli
Ranch Hand

Joined: Dec 24, 2004
Posts: 116
Sony,

The javac.exe is the java compiler. java.exe is the runtime launcher. both of them are needed if you want to do any development with Java.


Marcus L´┐Żubli, SCJP 1.4, CLP 5.0, SCWCD 1.4 (preparing)
Michael Weber
Greenhorn

Joined: May 11, 2005
Posts: 15
Originally posted by Marcus Laubli:
Sony,

The javac.exe is the java compiler. java.exe is the runtime launcher. both of them are needed if you want to do any development with Java.


Yes, they are both there, but still I can't compile any files
What do you think it's the problem?
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Originally posted by Sony:


My JDK is placed at C:\Java\jdk1.5.0_03
Even though I tried what you suggested, I get the message "The System cannot find the path specified."

The path I've put in system is "%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Java\jdk1.5.0_03"

I tried many things so far, but none has worked
Thanks for your comments guys.




Change the last entry in the path list above by appending "\bin" on the end. This should fix the problem.

Layne


Java API Documentation
The Java Tutorial
Michael Weber
Greenhorn

Joined: May 11, 2005
Posts: 15
Originally posted by Layne Lund:


Change the last entry in the path list above by appending "\bin" on the end. This should fix the problem.

Layne


Just did it. Now I am not getting the message like before, but I am getting an error on every attempt to compile applications which are written as in the book (so there can't be an application that's wrong). The error says: "Error. Cannot read: "Application's name. 1 error."

If I use just javac application (without .java extention), then I get just a default compile code not related to my application). If I use the extention, like I am supposed to, the error I already mentioned occurs.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

"Sony"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Arjun K
Ranch Hand

Joined: Mar 09, 2005
Posts: 39
Sony,
First you should know to set path and class path. Check this link which helps to set path and class path.
http://www.cs.ucsb.edu/~teliot/Path_and_Classpath.htm
Anyway also try this: "set PATH=C:\Java\jdk1.5.0_03\bin;%PATH%"
HTH
Arjun
Michael Weber
Greenhorn

Joined: May 11, 2005
Posts: 15
Originally posted by Mark Spritzler:
"Sony"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark


Hi Mark. Thanks for welcoming me . I changed the display name
Jon Egan
Ranch Hand

Joined: Mar 24, 2004
Posts: 83
A couple of common problems:

1. What editor did you use to create the file with your java source code? Typically when you're just starting out, it's best to use something simple like Notepad on the PC or vi on UNIX, so the output files are actually plain text - a common mistake is to edit them in something like Word, and save them as MyFile.java, only to realize later they've been saved as "MyFile.java.doc", in Word format.

2. Case (UPPER/lower) matters, with the class name inside the source file, and with the filename. Perhaps you made a source file named "MyClass.java", but you're trying to compile with "javac myclass.java"? If you had a problem with the capitalization of the class name in the file, the compiler should give a more informative error.

3. Is the class declared as public? It should be.

Past that, I don't know... If you can, copy/paste into your post exactly the command line and the error you are getting, because I wasn't able to recognize the error you paraphrased in your most recent post. Also include relevant info, like the name of the file (maybe also paste in a DIR listing, too, so you can have several extra sets of eyes looking for the problem).

Good luck
-- Jon
Michael Weber
Greenhorn

Joined: May 11, 2005
Posts: 15
Originally posted by Jon Egan:
A couple of common problems:

1. What editor did you use to create the file with your java source code? Typically when you're just starting out, it's best to use something simple like Notepad on the PC or vi on UNIX, so the output files are actually plain text - a common mistake is to edit them in something like Word, and save them as MyFile.java, only to realize later they've been saved as "MyFile.java.doc", in Word format.

2. Case (UPPER/lower) matters, with the class name inside the source file, and with the filename. Perhaps you made a source file named "MyClass.java", but you're trying to compile with "javac myclass.java"? If you had a problem with the capitalization of the class name in the file, the compiler should give a more informative error.

3. Is the class declared as public? It should be.

Past that, I don't know... If you can, copy/paste into your post exactly the command line and the error you are getting, because I wasn't able to recognize the error you paraphrased in your most recent post. Also include relevant info, like the name of the file (maybe also paste in a DIR listing, too, so you can have several extra sets of eyes looking for the problem).

Good luck
-- Jon


Hi Jon. Thanks for your post. Here is the path variable that I have defined under environment variables "%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Java\jdk1.5.0_03\bin"

Initally I made a mistake by deleting the current path, but this is what I have now. I saved a basic java file that I wanted to use just to check if the compiler is working, and I named it Party.java
Party.java is saved in the bin directory. When I try to compile it using the javac Party.java I get the following output:
"Error: cannot read: Party.java
1 Error"

Do you recognize by any chance where am I going wrong here

Thanks a lot for your help guys
Michael Weber
Greenhorn

Joined: May 11, 2005
Posts: 15
Now its even worse, when I try to compile a file I get an error "javac is not recognized as an internal or external command"
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
i'm not sure you'll like my idea:

make a clean install: delete ALL previous java installs - everything!

use control panel and make sure nothing is left

install

create a dir to keep java files - never inside java install dir

assure you create your JAVA_HOME properly

try typing javac

try typing java -version

compile

hopefully, run

good luck

EDIT:
i forgot to say:
clean your environment vars before re install
create a simple Hello.java from a simple text editor
then compile and run
[ May 16, 2005: Message edited by: miguel lisboa ]

java amateur
Michael Plourde
Greenhorn

Joined: May 17, 2005
Posts: 1
I was having the same exact error today, I had to make sure javac and the party.java was in the same bin folder and that fixed it for me, besides the left out semicolon after the button c line.

I am there with you, hang in there!

Michael Weber
Greenhorn

Joined: May 11, 2005
Posts: 15
I made a clean install of everything and still the same thing
If I try to compile a file that is placed in the bin folder I just get the same line again such as C:\Program Files\Java\jdk1.5.0_03\bin - nothing else.

The path variable I have is "%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Java\jdk1.5.0_03\bin ;C:\Program Files\Common Files\Autodesk Shared\"

Is there a solution to this night mare
Michael Weber
Greenhorn

Joined: May 11, 2005
Posts: 15
Originally posted by Michael Plourde:
I was having the same exact error today, I had to make sure javac and the party.java was in the same bin folder and that fixed it for me, besides the left out semicolon after the button c line.

I am there with you, hang in there!



It's good to know there is more of us out there
Cheers mate
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Open a command window, enter the following and tell us what is displayed after each of them.

path
java -version
javac


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Michael Weber
Greenhorn

Joined: May 11, 2005
Posts: 15
Command Path:
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Java\jdk1.5.0_03\bin ;C:\Program Files\Common Files\Autodesk Shared\

Command Java -version:
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)

C:\Program Files\Java\jdk1.5.0_03\bin>javac
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are u
sed
-classpath <path> Specify where to find user class files
-cp <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-endorseddirs <dirs> Override location of endorsed standards path
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release

-target <release> Generate class files for specific VM version
-version Version information
-help Print a synopsis of standard options
-X Print a synopsis of nonstandard options
-J<flag> Pass <flag> directly to the runtime system


Note that the starting command prompt does not start from the Java\bin but from Docummens and Settings\... (I had to change that to get javac output).
Thanks
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Originally posted by Michael Weber:
Command Path:
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Java\jdk1.5.0_03\bin ;C:\Program Files\Common Files\Autodesk Shared\

When you look in the C:\Program Files\Java\jdk1.5.0_03\bin directory (using Windows Explorer or something similar), do you see a file named javac.exe?

Normally, you will save your source (Party.java not party.java) file somewhere other than in the bin directory. The key is that after the path to the javac.exe file is in your PATH, you want to type

javac Party.java

while you are sitting in the same directory where the source file lives. It can be in C:\Java\ or in C:\foo.

cd to that directory and be sure to type the exact name of the source file. Be sure that the editor has not changed the name of the source file (Notepad sometimes changes it to something like Party.java.txt for example).
[ May 19, 2005: Message edited by: Marilyn de Queiroz ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Your PATH is wrong, you should not have to cd to C:\Program Files\Java\jdk1.5.0_03\bin in order to execute javac.

Part of your PATH looks like this:

C:\Program Files\Java\jdk1.5.0_03\bin ;

Remove that character after \bin so that your PATH looks like this:

C:\Program Files\Java\jdk1.5.0_03\bin;

That should correct your PATH and enable you to run javac.

Incidentally, the reason that java.exe is found is that it is probably located in C:\WINDOWS\system32. If you wish to ensure that you run java.exe in C:\Program Files\Java\jdk1.5.0_03\bin, then place C:\Program Files\Java\jdk1.5.0_03\bin at the front of your PATH. Doing it this way ensures that you don't compile with one JDK version but possibly run with another.
 
wood burning stoves
 
subject: can't start compiler