File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes IDEs, Version Control and other tools and the fly likes Java vs. Java.exe? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Java vs. Java.exe?" Watch "Java vs. Java.exe?" New topic
Author

Java vs. Java.exe?

Richard Mays
Greenhorn

Joined: Oct 09, 2013
Posts: 2
I'm running into problems loading a Java IDE due to it not being able to find the JRE. I set the environment variables as instructed, but this didn't help.

While troubleshooting the problem, I ran into something strange. I opened the command prompt and tried to get my JRE version by typing 'java.exe -version'. It threw the following error:
"C:\Documents and Settings\End User>"C:\Program Files\Java\jre7\bin\java.exe" -version
Error: loading: C:\Program Files\Java\jre7\bin\msvcr100.dll
Error: loading: C:\Program Files\Java\jre7\bin\client\jvm.dll

I then ran the same command, but without the .exe. The result is that it worked, as shown below.
"C:\Documents and Settings\End User>"C:\Program Files\Java\jre7\bin\java" -version
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Client VM (build 24.0-b56, mixed mode, sharing)

I'm running Windows XP SP3

Can anyone tell me what is the difference between running 'java.exe' and 'java'? What can I do to get the 'java.exe' command to work correctly?

Thanks!

Richard
Stuart A. Burkett
Ranch Hand

Joined: May 30, 2012
Posts: 679
Running a program without specifying an extension means that Windows will try to run an executable file with that name. An executable file could be any file with a .exe, .cmd or .bat extension (there may be others). I'm not sure what Windows does if it finds multiple matching executable files.
Have a look in the C:\Program Files\Java\jre7\bin directory and see if there are any other java.xxx files and then try runing these with the extension. This should give you an indication of which one Windows is running automatically.

When you find it, if it's a .cmd or .bat file then they will probably ultimately call jave.exe but they may do some required configuration first. Both are text files so you can look at their contents to see how they work.
Ravi Khadgi
Greenhorn

Joined: Aug 06, 2010
Posts: 20

Is your Java IDE trying to find JRE or JDK?
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2176
    
  47
Stuart A. Burkett wrote:I'm not sure what Windows does if it finds multiple matching executable files.

In the good old days of DOS and early Windows it was: .com .exe .bat
These days there is a PATHEXT environment variable which defines the order. ie the order the extensions are listed in is the order of preference. If the PATHEXT variable isn't defined I guess it reverts to the DOS order probably with .cmd coming after .bat.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
Welcome to the Ranch
I never knew you could write java.exe -version. You usually simply write java.
As well as running java -version, run javac -version; you should get a result like javac 1.7.0_40. That Java version is as far as I know the most recent available. There is usually only one “java” file in the bin folder: on a Windows box it is java.exe. I have opened my Windows folder and this is its contents
appletviewer.exe java-rmi.exe jrunscript.exe pack200.exe
apt.exe javaw.exe jsadebugd.exe policytool.exe
extcheck.exe javaws.exe jstack.exe rmic.exe
idlj.exe jcmd.exe jstatd.exe rmid.exe
jabswitch.exe jconsole.exe jstat.exe rmiregistry.exe
jar.exe jdb.exe jvisualvm.exe schemagen.exe
jarsigner.exe jhat.exe keytool.exe serialver.exe
javac.exe jinfo.exe kinit.exe servertool.exe
javadoc.exe jli.dll klist.exe tnameserv.exe
java.exe jmap.exe ktab.exe unpack200.exe
javafxpackager.exe jmc.exe msvcr100.dll wsgen.exe
javah.exe jmc.ini native2ascii.exe wsimport.exe
javap.exe jps.exe orbd.exe xjc.exe
There are no bat or cmd files in it.

As you say, you appear to have set up your PATH correctly.

Which IDE are you using? You usually have to tell it where to find a java executable, by directing its path to the JDK folder. It varies from IDE to IdE, but you usually direct it to one folder higher than the bin folder. If your PATH is c:\Program Files\Java\jdk1.7.0_40\bin, then direct the IDE to c:\Program Files\Java\jdk1.7.0_40. If there is a space in the PATH, you may need to enclose it in "" quotes.

I think this sounds more like an IDE problem; if I pass you to our IDEs forum, you might get better attention there.
Richard Mays
Greenhorn

Joined: Oct 09, 2013
Posts: 2
Thanks for the answers!

I checked for .BAT, .COM and .CMD files but could not find any in the JRE folder. I also tried changing to the JRE folder before running the 'java' vs. 'java.exe' test, and the results were the same. I will try enclosing the folder name in the PATH statement in quotes and see if that helps.

Ravi - based on the Command windows that pop up when the install is trying to find Java, it is looking in both the JRE and JDK folders. The paths it reports looking in are correct, but it still says it can't find a valid JRE.

Thanks again! Any further help will be greatly appreciated!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
Assuming you get that response from java -version and a sensible response from javac -version, your PATH environment variable appears correct. I presume you can run Java® programs from the command line, but it is the IDE you are having problems with.
Which IDE is it?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java vs. Java.exe?
 
Similar Threads
javac path issue
New FAQ from a Newbie to Java!
can't compile .java file
jusched.exe crashes
.class won't open, what do I need to download?