Howto start eclipse in JDK? - eclipse

I just installed a Maven plug-in into eclipse the first time. Now there is a message on eclipse startup, that i should start eclipse in JDK not jre to make Maven components run fine. There is a -vm argument which I used in the eclipse.ini:
-vm C:\Program Files (x86)\Java\
But the message is still there after restart.
I've tried the:
C:\Program Files (x86)\Java\bin
and also the:
C:\Program Files (x86)\Java\bin\java.exe
But nothing changed.
How do I start eclipse in JDK?
Thanks in advance.

If you're using Windows, right click on your eclipse shortcut and select Properties, in the Shortcut tab you can change what's in the Target: box to specify the jdk. I use
"C:\Program Files\eclipse-jee-galileo-sr1 (3.5.1)\eclipse.exe" -vm "C:\Program Files\Java\jdk1.6.0_16\bin\javaw.exe" -vmargs -Xmx1024m -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode
For some reason I couldn't get it to use the jdk when I tried editing the eclipse.ini file.

You can specify which JVM to launch Eclipse under in your eclipse.ini file. There are detailed instructions for different operating systems on the Eclipse wiki.

Found how to add it to the INI, must add the parameter to the line below the -vm option, as below:
-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-product
org.eclipse.epp.package.jee.product
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vm
C:\Program Files\Java\jdk1.6.0_17\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m

You have many more options in the Equinox Launcher page.
And you have an example of a complete eclipse.ini with all options there.
When no -vm is specified, the launcher looks for a virtual machine first in a jre directory in the root of eclipse and then on the search path. If java is found in either location, then we look for a jvm shared library (jvm.dll on window, libjvm.so on *nix platforms) relative to that java executable.
If a jvm shared library is found we load it and use the JNI invocation api to start the vm.
If no jvm shared library is found, we exec the java launcher to start the vm in a new process.
-vm specified on command line or in eclipse.ini
Eclipse can be started with "-vm <location>" to indicate a virtual machine to use. There are several possibilities for the value of <location>:
java.exe/javaw.exe: <location> is a path to a java launcher. We exec that java launcher to start the vm in a new process.
jvm.dll or libjvm.so: <location> is a path to a jvm shared library. We attempt to load that library and use the JNI Invocation API to start the vm in the current process.
vmDesc.ee: <location> is a path to a file ending in ".ee". This file is expected to describe the execution environment for a jvm. See the Execution Environment Descriptions page.
directory: <location> is a directory. We look in that directory for:
(1) a default.ee file,
(2) a java launcher or
(3) the jvm shared library.
If we find the jvm shared library, we use JNI invocation.
If we find a launcher, we attempt to find a jvm library in known locations relative to the launcher.
If we find one, we use JNI invocation. If no jvm library is found, we exec java in a new process.

Related

Eclipse Plugin --add-exports Java 16+

Using the google-java-format eclipse plugin works great when running Eclipse under Java 11, but when running on Java 16+, it fails with the following error:
Full error: A save participant caused problems. The save participant 'Code Clean Up' caused an exception: java.lang.IllegalAccessError: class com.google.googlejavaformat.java.JavaInput (in unnamed module #0x99c5646) cannot access class com.sun.tools.javac.parser.Tokens$TokenKind (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.parser to unnamed module #0x99c5646. See the error log for details.
The google-java-formatter does note that when running on JDK 16+, you need to set the --add-exports flag when running the formatter, due to JEP-396 (strong encapsulation of JDK Internals). What isn't clear is how to tell set --add-exports for Eclipse plugins.
Adding the following to eclipse.ini (or in my case SpringToolSuite4.ini) doesn't seem to help (not to mention it feels wrong since its not targetting that particular plugin). Is there a different way to approach/fix this?
-vmargs
-Dosgi.requiredJavaVersion=11
-Dosgi.dataAreaRequiresExplicitInit=true
-Xms256m
-Xmx2048m
--illegal-access=permit
--add-modules=ALL-SYSTEM
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
Just like xDeyan said above, your eclipse.ini file must have the following lines below the -vmargs line
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
This has been tested and works with JDK17
For anyone still having this issue running on JDK 17, just add = between the --add-exports like so:
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED

Lombok not working with Eclipse Neon 2 on macOS Sierra

Am using Eclipse Neon 2 on macOS Sierra and Lombok 1.16.14.
When I ran the Lombok Installer, it could not find any of my Eclipse or IntelliJ IDEA installations.
So, I had to manually "Specify Location" by pointing to the following file (no other directory or file would enable the "Install" button to become clickable):
eclipse-standard-neon2/Eclipse.app/Contents/Eclipse/eclipse.ini
After, installing, it said that "Installation was completed" and inside the eclipse.ini file, it had the following line inserted for the last line ( I pasted the full contents of the eclipse.ini ):
-startup
../Eclipse/plugins/org.eclipse.equinox.launcher_1.3.201.v20161025-1711.jar
--launcher.library
../Eclipse/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.401.v20161122-1740
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.8
-XX:+UseG1GC
-XX:+UseStringDeduplication
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m
-Xdock:icon=../Resources/Eclipse.icns
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
-javaagent:../Eclipse/lombok.jar
lombok.jar was also automatically placed inside the same directory as eclipse.ini:
eclipse-standard-neon2/Eclipse.app/Contents/Eclipse/
However, when I launch Eclipse Neon 2 and trying to use any of the Lombok annotations, its fails to recognize the library in its classpath, even if I declare package import explicitly.
Also, when I re-run the Lombok Installer (in order, to uninstall Lombok), it still can't find the previous Eclipse IDE that I had to manually specify from the previous install?
When I tried to run Eclipse from the command line using the following (it still didn't work and there were no errors listed in stdout):
eclipse-standard-neon2/Eclipse.app/Contents/MacOS$ ./eclipse -vmargs -javaagent:../Eclipse/lombok.jar
Here's the stdout from running it from stdout:
objc[52949]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/MacOS/libjli.dylib (0x100543480) and /Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x1005a54e0). One of the two will be used. Which one is undefined.
org.eclipse.m2e.logback.configuration: The org.eclipse.m2e.logback.configuration bundle was activated before the state location was initialized. Will retry after the state location is initialized.
Starting Groovy-Eclipse compiler resolver. Specified compiler level: unspecified
671 2.4.8.xx-201702132212-e46 = STARTING
672 2.3.11.xx-201702132212-e46 = STARTING
org.eclipse.m2e.logback.configuration: Logback config file: /Users/devuser/DevTools/Java/eclipse/eclipse-standard-neon2/workspace/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.7.0.20160603-1933.xml
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [bundleresource://462.fwk1881585646:1/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [bundleresource://462.fwk1881585646:2/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
org.eclipse.m2e.logback.configuration: Initializing logback
Has anyone run into this issue?
Guess, I am not going to have the privilege of using / learning Lombok anytime soon. :(
You can verify if Lombok is installed correctly by opening the Help 🢒 About Eclipse dialog from the menu. In the white area on the right, the bottom line should read: Lombok v1.16.14 "Candid Duck" is installed. https://projectlombok.org/
If it doesn't, please verify your eclipse.ini. Make sure that the line -javaagent:../Eclipse/lombok.jar is below -vmargs. You can try using a full path here, it might be resolved from the wrong location.
If the line is there, but the lombok line is not display in the dialog, try to start Eclipse from the command line, and see if you get error messages.
The next version of lombok should find this installation.
The reason why the uninstaller doesn't suggest the previously entered location is that the lombok installer doesn't try to remember anything. The upside is that directory moves don't interfere, and the lombok installer doesn't leave any traces on your computer.
Disclosure: I am a lombok developer.

Jenkins SBT plugin fails with classpath error

I'm trying to get the Jenkins SBT plugin working, which involves referencing the launcher jar, rather than the full SBT install.
This results in "class not found errors", which I believe is because the manifest does not contain the appropriate classpath to allow the launcher to be run like this:
java -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M -Dsbt.log.noformat=true -jar /path-to/sbt/sbt-launch.jar package
However, this is exactly how the manual installation instructions at http://www.scala-sbt.org/0.13/tutorial/Manual-Installation.html say it should run.
Have I missed something, or should I be filing a bug report (either with the jenkins SBT plugin team or with SBT)?
EDIT: On closer inspection, it's actually failing due to "java.io.EOFException: Unexpected end of ZLIB input stream". I'll investigate this further and update my own question, as I have seen a few other people run into this same problem with SBT.
Try:
java -Xms512M -Xmx1536M -Xss1M -XX:MaxPermSize=256M -Dsbt.log.noformat=true -jar /path-to/sbt/sbt-launch.jar
If you create own file use (bash script):
java -Xms512M -Xmx1536M -Xss1M -XX:MaxPermSize=256M -Dsbt.log.noformat=true -jar /path-to/sbt/sbt-launch.jar "$#"
Note:
-XX:+CMSClassUnloadingEnabled is only valid for CMS Garbage collector. If you use java 7+ you can remove it. For java 8 remove also -XX:MaxPermSize=256M

Can't deploy app engine project (for jsp file)

When i deploy my eclipse appengine project their is no error and successfully deployed. But when i add a .jsp file in my war folder, i can't deploy. The error message is ==> java.lang.RuntimeException: Cannot get the System Java Compiler. Please use a JDK, not a JRE.
my eclipse jre home definition is ==>
eclipse.ini
pc environment variable
and path
Where is the problem??? I cant understand? Please help someone...
In the eclipse.ini file the change is ==>
-vm
C:\Program Files (x86)\Java\jdk1.7.0_15\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.7
-Dhelp.lucene.tokenizer=standard
-Dosgi.requiredJavaVersion=1.7
Dosgi.requiredJavaVersion=(must be the java version.)

m2eclipse: Eclipse is running in a JRE, but a JDK is required

I have a problem with m2eclipse (0.10.0) together with eclipse galileo (Build id: 20090920-1017).
I always get the error message:"Eclipse is running in a JRE, but a JDK is required". I have tried several things, but nothing works. The error message is still there. Here are the things I have tried:
In Window>Preferences>Java>Installed JREs I checked JDK1.6.0_20. DOES NOT WORK
In Window>Preferences>Java>Installed JREs I removed all JREs. Only the checked JDK1.6.0_20 is still there. DOES NOT WORK
In Window>Preferences>Java>Installed JREs>Execution Environments I choosed JavaSE-1.6 and checked JDK1.6.0_20[perfect match]. DOES NOT WORK.
In Preferences of the eclipse desktop start icon I added the -vm parameter (C:\Programme\eclipse_galileo\eclipse\eclipse.exe -vm C:\Programme\Java\jdk1.6.0_20\bin). DOES NOT WORK.
I added the clean parameter (C:\Programme\eclipse_galileo\eclipse\eclipse.exe -vm C:\Programme\Java\jdk1.6.0_20\bin -clean). DOES NOT WORK.
I added the -vm parameter to the eclipse.ini file with a carriage return after -vm and C:/Programme/Java/jdk1.6.0_20/bin/javaw.exe in a new line. DOES NOT WORK.
After doing all these things I removed the m2eclipse plugin and installed it once again. DOES NOT WORK.
New ideas I have tried:
In Preferences of the eclipse desktop start icon I put the executable at the end (C:\Programme\eclipse_galileo\eclipse\eclipse.exe -vm C:\Programme\Java\jdk1.6.0_20\bin\javaw.exe). DOES NOT WORK.
I changed in eclipse.ini the slashes to backslashes. DOES NOT WORK.
Here is my eclipse.ini file:
-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-product
org.eclipse.epp.package.jee.product
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vm
C:\Programme\Java\jdk1.6.0_20\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m
Is anyone out there who have other ideas? Any help is appreciated.
Thank You very much.
GernoK
Unbelievable, the solution to this problem has nothing to do with slashes, backslashes, quotes, spaces, jre, jdk, jvm, javaw, ....
The answer is that you have to have a line break between
-vm
and the path.
So in the eclipse.ini file:
THIS WILL NOT WORK:
-vm C:\java\jdk\bin\javaw.exe
BUT THIS WILL:
-vm
C:\java\jdk\bin\javaw.exe
MARIO-ORTEGON answered is the right answer to this problem. The only thing you need to do is to move this line "-vm C:\java\jdk\bin\javaw.exe" under the section -product org.eclipse.epp.package.jee.product in eclipse.ini. like this:
-product
org.eclipse.epp.package.jee.product
-vm
C:\java\jdk\bin\javaw.exe
save and restart the eclipse. Error will be gone.
I think these are answers needed when editing the eclipse.ini or STS.ini files:
A lot of people make these mistakes because they make certain assumptions (which is not correct):
Mistake #1: Writing the parameters in the same line. Unlike JVM command line, Eclipse expects every parameters to be placed in different line in its eclipse.ini file.
One of the most common mistake is (which should be written in 2 separated lines):
-vm c:/Java/jdk1.6.0_31/bin/javaw.exe
Mistake #2: Writing the -vm and -vmargs in the wrong order. Sequence does matter. The -vmargs has to be put before the -vm. Why? Because once the -vm has been specified, the VM will be fully specified and the rest of the -vmargs will be ignored.
Mistake #3: Assuming the eclipse.ini will stay the same if you don't change it. Some plugins installation may have auto configuration (which after restarting automagically change the eclipse.ini file, or other .ini config file, e.g. STS.ini if you are using SpringSource Tool Suite for example), they will append indiscriminately the -vm before the -vmargs. Check for double occurrence of -vm or -vmargs.
Mistake #4: Pointing to the path of JVM, instead of the binary when specifying -vm. Eclipse expects the Java JVM binary, not just the JAVA_HOME path e.g. -vm c:/Java/jdk1.6.0_31/bin/javaw.exe not just -vm c:/Java/jdk1.6.0_31
For the original question, it seems the Mistake #2 is the cause. Instead of the one, you should move the -vm to the end, after -vmargs:
-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-product
org.eclipse.epp.package.jee.product
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m
-vm
C:\Programme\Java\jdk1.6.0_20\bin\javaw.exe
I had the same problem with Eclipse reporting that it was running in the JRE (Win7 x64, 32 Bit JDK 1.6 update 21), even though I was specifying that it should use the JDK.
I finally deleted JRE6 which is optionally installable with the JDK and the message disappeared.
Someone with a deeper understanding of Windows will have to explain why it does this, but it is apparently ignoring the eclipse.ini setting, as well as JAVA_HOME and starting eclipse in the JRE anyway.
My eclipse.ini:
-vm
C:/Java/jdk1.6.0_21/bin/javaw.exe
-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-product
org.eclipse.epp.package.jee.product
-nosplash
org.eclipse.platform
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms32m
-Xmx1024m
-Xss6m
-XX:PermSize=32m
-XX:MaxPermSize=256m
-XX:CompileThreshold=5
-XX:MaxGCPauseMillis=10
-XX:MaxHeapFreeRatio=70
-XX:+UseParallelGC
-XX:+AggressiveOpts
-Dcom.sun.management.jmxremote
JAVA_HOME
C:\Windows\system32>echo %JAVA_HOME%
C:\Java\jdk1.6.0_21
I think you have to explicity add the executable to the -vm argument:
C:\Programme\eclipse_galileo\eclipse\eclipse.exe -vm C:\Programme\Java\jdk1.6.0_20\bin\javaw
Regarding the ini file, it depends on the full contents. What does your ini file contains?
Put these lines at the beginning of the eclipse.ini file:
-vm
G:/dev/jdk1.6.0_19/bin/javaw.exe
I'm getting the same error message as soon as I remove these two lines
-vm
C:\Programme\Java\jdk1.6.0_10\bin\javaw.exe
from my eclipse.ini file.
Maybe you should use backslashes in that eclipse.ini.
There are two JVMs involved here; the one that Eclipse is running in and the one (or more) that the different projects in your workspace run in. I think this message refers to the JVM that Eclipse is running in. So, the solution is not contained in the "Installed JREs" section within Eclipse. It's the JVM that's in your path within Windows.
Java may be finding its files using the JAVA_HOME environment variable. Try changing it to C:\Programme\Java\jdk1.6.0_20
In Windows XP, this is under Control Panel, System, Advanced tab, Environment Variables button.
Uninstall the JRE leaving ONLY the JDK and private JRE behind. Run Eclipse, and it will immediately complain that it can't find a JRE or JDK (assuming the -vm option is missing or wrong in your ini).
Now put the -vm path to javaw in your ini file, save and Eclipse will now load the JDK.
I actually went ahead and uninstalled everything Java and then reinstalled JDK 6 leaving out the public JRE and the database portion of the install.
The uninstall method is the only thing that worked for me. No amount of -vm magic made it happen until I only had the JDK installed.
I had the same problem but solved it. Add the -vm option as the first line in your eclipse.ini file and it will work.
Try adding this:
-vm E:\java\jdk1.6\jre\bin\client\jvm.dll
I too had this issue.
This problem disappeared when I upgrade to Eclipse Indigo. So try with Higher version.
Check your Installed JRE setting of Eclipse. It should point to JDK rather than JRE. Though it is a JRE setup. Remember JDK contains JRE and when Maven runs it tries to find out JDK mostly tools.jar.