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.
Related
So I've recently made a small app for a high school class, and I want it to be able to run on any Windows computer with JRE installed and updated.
I've made the app in Eclipse, exported it as a runnable JAR file (making sure to have "Package required libraries into generated JAR" selected under Library handling), and then converted that to an executable file using Launch4J. When I first made the exe, under the JRE specification, I had the min JRE version set to 1.8.0 and I originally had the option selected that said "Prefer public JRE, but use JDK runtime if newer," not thinking anything of it. The exe worked perfectly fine on my computer, so I sent it out to a few friends to have them test it out, and it didn't work.
Turns out what had happened was the exe was running using my version of JDK, instead of using JRE. I tried making the executable again, this time selecting the option of "Only use public JREs." When I built the executable this time, it wouldn't run on my computer either, even though I have the latest JRE version installed, so I obviously think that somehow the runnable JAR file is being built without being able to be ran using JRE instead of JDK.
I've looked in the export options for eclipse, but from what I can tell there's nothing I can change when exporting the runnable jar file to change how it runs.
Any help would be greatly appreciated.
Okay, so after some digging into the settings on a project I figured out how to get it to work.
You need to right click on the project you're working on in Eclipse.
Properties > Java Compiler
Under JDK Compliance, you need to uncheck "Use compliance from execution environment
'JavaSE-14' on the 'Java Build Path'
Then under "Compiler compliance level:" you need to click on the drop down and choose 1.8.
After that you can export it as a runnable JAR and then convert it to .exe and everything should work perfectly!
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 have just installed Eclipse Indigo, and created a new project. It's telling me that the build path is not configured.
I have followed RighClick on the project -> Build Path -> Configure Build Path -> Libraries and there I found JRE System Library [jre1.8.0_31] and I don't understand why it doesn't recognize it.
Any help?
First of all you have to know some stuffs about JAVA. Java uses a JVM (Java virtual machine) wich is the JDK and need to be installed on your computer.
The JDK makes the JVM run and the JRE allow you to compile etc java class. (No need for both, just install the JRE)
see this page.
Then you'll have to configure a window GLOBAL VARIABLE. The JAVA_HOME var.
"1-Right click My Computer and select Properties.
2-On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located".
This way Eclipse will be able to find the installed JRE.
Finally, in eclipse, check that it know the JRE.
And that's it. There is a lot of info over the web about this for more details.
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.
this is hopefully something simple but... Eclipse has been working relatively fine for everything except deploying to GAE.
I can run my GAE app locally, but when I try to deploy to google, I get this message:
java.lang.RuntimeException: Cannot get the System Java Compiler. Please use a JDK, not a JRE.
I have set the build path to JDK.
It also happens when trying to deploy the same project from more than one system (win7 and win8) so I suspect the problem is to do with the project itself. This particular project is existing and already running on google for years.
Interesting that this error only shows up when I have .jsp files in my app to deploy. If I remove the jsp files, it deploys without error. (kinda need the jsp files tho)
thanks
link to image of my build path
I had the same problem and was able to deploy successfully after forcing Eclipse to use
the JRE within my SDK directory (Win 7 64bit). To force Eclipse to use a particular JRE see this. It seems that the JVM that Eclipse uses, the JVM that app engine spawns, & the JVM that appconfig uses should all be the same. Hope this helps w/ your situation as well.
I tried setting my project jre to be the same as my eclipse jre according to AlohaCode's answer. This was insufficient for me. The answer was in my classpath, there is java.exe in C:\windows\system32 which was BEFORE my java home variable.
The solution is to put the java home path before the C:\windows\system32 entry.
I found the answer here: 2FL5sJ">https://groups.google.com/forum/?fromgroups=#!msg/google-appengine-java/RyFybJWUhU4/78UE_2FL5sJ
In Eclipse, go to: Window->Preferences->Java->Installed JREs , add->Standard VM TO JDK PATH\JRE. and If you had a JRE checked previously uncheck it and check this jre
The given advice solved my problem. The -vm argument cannot be the first line.
-vm
C:\Program Files (x86)\Java\jdk1.7.0_51\bin\javaw.exe
Setting -vm in eclipse.ini did not help. All other settings were seemingly pointing to the JDK. Out of desperation, I uninstalled all JREs from my system, leaving only the JDK. The consequence was that Eclipse would not start as the JDK bin directory was not on my PATH (Windows 8 here). Adding this in environment system variables got Eclipse to start. Thereafter I could deploy to app engine.
Removing the JRE file located in my C:/Program Files(*86)/Java folder , reopening the eclipse IDE resolved the issue.
I had Java JDK installed in my C:/Program Files/Java folder which was not detected earlier.