According to the Eclipse FAQ. I read that
Eclipse DOES NOT consult the JAVA_HOME environment variable.
My doubt is how does eclipse initializes the Virtual Machine. It does not know the location of Java. My eclipse.ini file does not have -vm configuration. Still I am able to run eclipse.
The Source
UPDATE
According to Eclipse Installation Guide. Eclipse does not write entries to the Windows registry.
As far as I know, to invoke the JVM, Eclipse executes the java command, so, if it's at your system execution path, Eclipse won't need to find the instalation directory.
To check, you can start a OS shell and execute the next command (from any location):
> java -version
EDIT: I was (partially) wrong. From the FAQ (http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F#Find_the_JVM)
If a JVM is installed in the eclipse/jre directory, Eclipse will use
it; otherwise the launcher will consult the eclipse.ini file and the
system path variable
So, Eclipse first looks inside its eclipse/jre dir for installed VMs, if empty, consults the eclipse.ini file, and at last, looks at the system path.
Even Help->Installation details->Configuration would give you the exact version and type of jvm you are using . Here it is clearly given in System Properties
Eclipse will run using whatever version of JRE you have installed. To see/edit the version being used, go to Preferences -> Java -> Installed JREs
Or just run a java program in Eclipse. Eclipse will show the full path of javaw command it is using.
Eclipse looks for system Path variable to get the installed JVM. It depends upon how you have defined path variable. Order in which several versions have been defined in path does matter i.e. if jdk1.5/bin is set before jdk1.6/bin, system will pick 1.5 version when you execute java -version on cmd
Solved!
1) downloaded and installed 64-bit versions of both the ADT for Android (Eclipse) and JDK Java bundle
2)updated the PATH environmental variables (Win Control panel...System...advanced opt...Envir.variables)
In my case it now looks like this:
C:\Program\Java\jre7\bin\client\jvm.dll;C:\Program\Java\jdk1.7.0_21\bin
(no backslash after the \bin directory)
These days on WIN64, oracle creates a couple of new directories and adds them to your path. The one eclipse will default to is the second directory you specify in the installation process, because that gets loaded at the head of the path ahead of your JAVA_HOME. It is confusing why they ask you for two directories, I have no answer for that. I blew away the second directory, removed the two added directories from the path, configure my JAVA_HOME environment variable (in my case already on the path pointing to an older version) accordingly, and eclipse is good to go.
Related
So I have java 1.6.0_65 and it is in my path and works, however it is not a recent enough version to install Eclipse. I have added the new version to my path through the bash_profile and bashrc. when $echo $PATH is ran, it shows java 1.8 but eclipse still only recognizes 1.6. have tried to disable 1.6 only to have java -version reveal nothing. Im not sure what exact information needed to help me solve this 3 day riddle, but ask and I will get it.
One way to force eclipse to start with a certain JVM is by turning to the eclipse.ini file.
Example: in my Linux system, I simply extracted the eclipse archive to /opt.
Directly in the root directory, there is an eclipse.ini.
(for me, that would be /opt/eclipse-jee-neon-2-linux-gtk-x86_64/eclipse.ini). You simply open that ini file in an editor and then you can use -vm in order to specify the java binary to use when eclipse starts.
See here for the official documentation - including a MacOS example.
I installed java(jdk and jre) along with eclipse.
I was having trouble with launching eclipse(was throwing jvm not found kind of error) and hence on googling found that I need to place the javaw.exe file inside the eclipse folder or update the vm location in .ini file to the bin folder of the jre.
Eclipse then started working fine.
However just to understand things in deep, I tried to remove the -vm location and also the javaw.exe file from eclipse folder.
Still I find that the java program in eclipse is running successfully. I was hoping for eclipse to throw the jvm not found type of error.
I am fairly new to java/eclipse but my understanding is that only jre is needed for running an existing java program.
Also I remember running java programs from command prompt where setting of environment variables were required. But while working on eclipse so such thing has been done. Is setting of environment variable not needed with eclipse?
Eclipse doesn't use environment variables to decide which JRE to use.
The JRE/JDKs that Eclipse can use to run a Java program are listed in the Preferences in the 'Java > Installed JREs' page.
You choose which JRE to use from the installed JREs list when you create each Java project. You can change the choice in the Properties for the Project on the 'Java Build Path' page.
I am working on a project on Processing and when I export the project and try to run it, it says that Java Runtime Enviroment is required. I have JRE 1.8.0_121 which is newer than the required one so i guess it shouldn't be problematic. I installed JDK but nothing changed. The project runs only when I export the project embedded for windows 64-bit (and then it doesn't let me delete it because some java processes appear). I have also tried updating the system variables JAVA_HOME and JRE_HOME.
Any help and ideas will be appreciated ^^
The problems just disappeared when I reinstalled Processing.
The JAVA_HOME and JRE_HOME variables don't matter in this case.
The only thing that matters is your PATH variable.
So you need to check what's on your PATH.
What happens when you type java -version in a command prompt?
What is currently on your path? Watch out for other versions of Java that have already been added!
If you still can't get it working, try running the executable from the command prompt so you can see exactly what error you're getting.
You might also try uninstalling (make sure you delete the settings directories as well) and reinstalling Processing.
I am trying to run java application and I am getting following error,
Unable to find a javac compiler; com.sun.tools.javac.Main is not on
the classpath. Perhaps JAVA_HOME does not point to the JDK
I have gone through many SO questions and found solution is JAVA_HOME should be point to JDK, not JRE.
Then I have tried to print JAVA_HOME in command prompt,
I had set this JAVA_HOME from my computer->properties->env variables -> system vars as below,
I had also added new variable in eclipse using preferences as,
And finally I am still getting the same error. Whats wrong with JAVA_HOME ?
Update :
In eclipse-preferences-installed jres there is only one entry is present and which is jdk and selected,
And under project properties java build path-libraries there is JRE System Liberary [jdk1.8.0_31] is used.
Update 1 :
C:\Program Files\Java\jdk1.8.0_31 have folder named jre. Is that jre folder causing this issue ? Can I remove this folder ? Is there is any way to add only jdk liberary in project ?
Eclipse is an IDE and as such, it has (at least) two Java versions: The one which it uses itself to run (JAVA_HOME) and a JVM which it uses to run your application. The two don't need to be the same.
So to fix your problem, you need to look into Eclipse's preferences, specifically Installed JREs which gives you a list of Java VMs which Eclipse will use to run Java code from projects. My guess is that there will be several entries there and the default will be a JRE instead of a JDK.
Make sure you have a JDK in the list and then go to your project. In the project, you can select which Java VM to use under Java Build Path -> Libraries.
[EDIT]
Look closely at the last screenshot: You've configured Eclipse to use C:\Program Files\Java\jdk1.8.0_31\jre which means you've pointed it at the JRE inside of the JDK. Use C:\Program Files\Java\jdk1.8.0_31 instead (without the \jre at the end).
[EDIT 2] If you delete the jre folder, Java will stop working. Any JDK also contains a JRE. The JRE contains rt.jar with String.class and the like. The Java compiler is in tools.jar which is in the JDK.
If recreating the JRE entry in Eclipse doesn't help, you'll have to add it manually to the classpath.
You can use a variable ("Add Variable...") to make sure Eclipse updates the path when you switch to a new/different JRE. Try JAVA_HOME with the extension lib/tools.jar
In Eclipse click Run->External Tools->External Tools Configurations
Click JRE tab
Click Installed JREs... button
Click Add button (select Standard VM, where applicable)
Click Directory Button
Browse to your JDK version (not JRE) of your installed Java (eg: C:\Program Files\Java\jdk1.7.0_04)
Click Finish.
Re-run Ant script - have fun!
I faced the same issue while i was using ant from command prompt and the solution which I found is that you need to put tools.jar inside bin folder which is present inside apache ant folder.
For eg :-
D:\apache-ant-1.10.12-bin\lib
You will get tools.jar inside
C:\Program Files\Java\jdk1.8.0_211\lib
Please change the path based on your java installation path.
I'm getting an error when trying to deploy an project to AppEngine using NetBeans.
I installed the plugin for NetBeans and I can run the application localy using appengine-java-sdk-1.9.0
When I try to deploy the program I get the following message:
Beginning interaction for module default...
0% Created staging directory at: 'C:\Users\Adi\AppData\Local\Temp\appcfg8079434123068806992.tmp'
5% Scanning for jsp files.
8% Compiling jsp files.
Error Details:
Mar 10, 2014 11:50:04 PM org.apache.jasper.JspC processFile
INFO: Built File: \guestbook.jsp
java.lang.RuntimeException: Cannot get the System Java Compiler. Please use a JDK, not a JRE.
Unable to update app: Cannot get the System Java Compiler. Please use a JDK, not a JRE.
Please see the logs [C:\Users\Adi\AppData\Local\Temp\appcfg5934545421821565182.log] for further information.
Thanks in advance.
First of all, this is my first answer in stackoverflow. Please consider, if I break some rules do not hesitate to tell me whats wrong or should be changed in future.
I run into same problem like Amir Rossert.
I've installed the Bundle "Netbeans 8 + JDK 8" (jdk-8u25-nb-8_0_1-windows-x64.exe from Oracle website). Additionally I have installed JDK 7 which I needed for different cases.
In Netbeans both JDKs were displayed under Tools/Java Platform Manager
JAVA SE
JDK 1.7
JDK 1.8 (Default)
So far so good.
When I changed JAVA_HOME to JDK 1.7 (C:\Program Files\Java\jdk1.7.0_72) I still get
java -version 1.8 !?
Why: Because Netbeans
has installed/copied 3 following files
java.exe
javaw.exe
javaws.exe
into C:\Windows\System32
linked them from directory C:\ProgramData\Oracle\Java\javapath and
after all set system variable Path (not PATH) = C:\ProgramData\Oracle\Java\javapath;
So whenever I wanted to use 1.7 it didn't work, instead 1.8 was used.
And when I wanted to deploy to Google Appengine the Exception occur: Caused by: java.lang.RuntimeException: Cannot get the System Java Compiler. Please use a JDK, not a JRE.
I solved it this way:
I deleted all three files mentioned above (java.exe, javaw.exe, javaws.exe)
I deleted the directory C:\ProgramData\Oracle\Java\javapath
I deleted the value C:\ProgramData\Oracle\Java\javapath; in system variable Path:
After that I tried out to deploy on Google Appengine again, this time successfully.
I just found an answer to this issue on:
appcfg can't find javac?1
Unfortunately it's more complicated than that. The very first entry in your path points to C:\Windows\system32. There is undoubtedly a java.exe living in that folder who's home is actually the JRE in C:\Program Files\Java\jre6. (You can test this yourself by running a small Java program):
System.out.println(System.getProperty("java.home"));
AppCfg uses the system property, java.home, of the currently running JVM to look for javac. Since you're running the java.exe which belongs to a JRE, it goes looking for the compiler there. Unfortunately, there's no real universally consistent or great way to automagically find the most appropriate java compiler. For our SDK, the rule is that you need to be running the JVM from your SDK, not from a JRE. As I mentioned in my previous post, this is most easily accomplished by just setting your Java SDK at the front of your path. For example,
set PATH=c:\Program Files\Java\jdk1.6.0\bin;%PATH%
We've certainly been mulling over ways to make this simpler and more bulletproof.
After editing the PATH I was able to deploy my app to the appengine with NetBeans.
I'm not familiar with NetBeans but I'll give you the steps to fix this on Eclipse hopefully you will find the equivalent ones:-
Right click on your project and choose properties
Go to java build path
Then under libraries tap, scroll to your selected JRE System Library
Edit the JRE to point to the directory where you installed you JDK.
If the above is already done, and you only see such errors when deploying, do the following
Edit the configuration settings file of your IDE and give it the following argument then restart it, in the Eclipse it is at the main directory where the Eclipse at and called eclipse.ini.
-vm
C:/Program Files/Java/jdk1.7.0_51/bin/javaw.exe