• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

can't start compiler

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whats with the percentage sign before the javac? Are you actually typing that in? You shouldnt be.
 
Michael Weber
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't type in the percentage sign, and still the same problem occurs. Thanks for replying though.
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 410
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 410
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Michael Weber
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Michael Weber
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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
 
Arjun K
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Open a command window, enter the following and tell us what is displayed after each of them.

path
java -version
javac
 
Michael Weber
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Water! People swim in water! Even tiny ads swim in water:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic