Eclipse ini java path

Setting the correct PATH for Eclipse

I am using Windows 8.1 environment. I had the same problem while running my first java program after installing Eclipse recently. I had installed java on d drive at d:\java. But Eclipse was looking at the default installation c:\programfiles\java. I did the following:

    Modified my eclipse.ini file and added the following after open:

After this, the program ran well and got the hello world to work.

Eclipse folder has an initialization file which is used by eclipse on launch/Double click it is named as eclipse.ini. Add the following lines in eclipse.ini file. Where the vm defines the path of JVM with which we want eclipse to use.

-vm C:\Program Files\Java\jdk1.8\bin\javaw.exe 

Make sure you have add the above lines separately and above the following line

--launcher.appendVmargs -vmargs 

Go to System Properties > Advanced > Enviroment Variables and look under System variables

First, create/set your JAVA_HOME variable

Even though Eclipse doesn’t consult the JAVA_HOME variable, it’s still a good idea to set it. See How do I run Eclipse? for more information.

If you have not created and/or do not see JAVA_HOME under the list of System variables , do the following:

  1. Click New. at the very bottom
  2. For Variable name , type JAVA_HOME exactly
  3. For Variable value , this could be different depending on what bits your computer and java are.
    • If both your computer and java are 64-bit, type C:\Program Files\Java\jdk1.8.0_60
    • If both your computer and java are 32-bit, type C:\Program Files\Java\jdk1.8.0_60
    • If your computer is 64-bit, but your java is 32-bit, type C:\Program Files (x86)\Java\jdk1.8.0_60

If you have created and/or do see JAVA_HOME , do the following:

  1. Click on the row under System variables that you see JAVA_HOME in
  2. Click Edit. at the very bottom
  3. For Variable value , change it to what was stated in #3 above based on java’s and your computer’s bits. To repeat:
    • If both your computer and java are 64-bit, change it to C:\Program Files\Java\jdk1.8.0_60
    • If both your computer and java are 32-bit, change it to C:\Program Files\Java\jdk1.8.0_60
    • If your computer is 64-bit, but your java is 32-bit, change it to C:\Program Files (x86)\Java\jdk1.8.0_60

Next, add to your PATH variable

  1. Click on the row under System variables with PATH in it
  2. Click Edit. at the very bottom
  3. If you have a newer version of windows:
    • Click New
    • Type in C:\Program Files (x86)\Java\jdk1.8.0_60 OR C:\Program Files\Java\jdk1.8.0_60 depending on the bits of your computer and java (see above ^).
    • Press Enter and Click New again.
    • Type in C:\Program Files (x86)\Java\jdk1.8.0_60\jre OR C:\Program Files\Java\jdk1.8.0_60\jre depending on the bits of your computer and java (see above again ^).
    • Press Enter and press OK on all of the related windows
  4. If you have an older version of windows
    • In the Variable value textbox (or something similar) drag the cursor all the way to the very end
    • Add a semicolon ( ; ) if there isn’t one already
    • C:\Program Files (x86)\Java\jdk1.8.0_60 OR C:\Program Files\Java\jdk1.8.0_60
    • Add another semicolon ( ; )
    • C:\Program Files (x86)\Java\jdk1.8.0_60\jre OR C:\Program Files\Java\jdk1.8.0_60\jre
Читайте также:  Kotlin standard library cookbook

Changing eclipse.ini

  1. Find your eclipse.ini file and copy-paste it in the same directory (should be named eclipse(1).ini )
  2. Rename eclipse.ini to eclipse.ini.old just in case something goes wrong
  3. Rename eclipse(1).ini to eclipse.ini
  4. Open your newly-renamed eclipse.ini and replace all of it with this:
-startup plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502 -product org.eclipse.epp.package.java.product --launcher.defaultAction openFile --launcher.XXMaxPermSize 256M -showsplash org.eclipse.platform --launcher.XXMaxPermSize 256m --launcher.defaultAction openFile -vm C:\Program Files\Java\jdk1.8.0_60\bin\javaw.exe -vmargs -Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx1024m 

XXMaxPermSize may be deprecated, so it might not work. If eclipse still does not launch, do the following:

  1. Delete the newer eclipse.ini
  2. Rename eclipse.ini.old to eclipse.ini
  3. Open command prompt
  4. type in eclipse -vm C:\Program Files (x86)\Java\jdk1.8.0_60\bin\javaw.exe

If the problem remains

Try updating your eclipse and java to the latest version. 8u60 ( 1.8.0_60 ) is not the latest version of java. Sometimes, the latest version of java doesn’t work with older versions of eclipse and vice versa. Otherwise, leave a comment if you’re still having problems. You could also try a fresh reinstallation of Java.

Eclipse doesn’t consult the JAVA_HOME variable

You should specify where Eclipse should find your JDK in the file eclipse.ini . Specifically, the following parameter (note that it is 2 separate lines in the ini file):

or wherever your javaw.exe happens to be.

Источник

Overview

Eclipse startup is controlled by the options in $ECLIPSE_HOME/eclipse.ini . If $ECLIPSE_HOME is not defined, the default eclipse.ini in your Eclipse installation directory (or in the case of Mac, the Eclipse.app/Contents/MacOS directory) is used.

eclipse.ini is a text file containing command-line options that are added to the command line used when Eclipse is started up. There are many options available, please see here.

  1. You can, and should, experiment with changes to the launch command from your Command Prompt/Terminal before changing the eclipse.ini itself.
  2. Each option and each argument to an option must be on its own line.
  3. All lines after -vmargs are passed as arguments to the JVM, so all arguments and options for eclipse must be specified before -vmargs (just like when you use arguments on the command-line)
  4. Any use of -vmargs on the command-line replaces all -vmargs settings in the .ini file unless —launcher.appendVmargs is specified either in the .ini file or on the command-line. (doc)
  5. -XX VM arguments are subject to change without notice, even during minor updates. If the JVM keeps exiting with code 2 instead of starting Eclipse, try removing them.
  6. Make a backup—keep a copy of the original contents on hand so you don’t break your installation and have to download it all again.
Читайте также:  Php if string begins with string

By default, eclipse.ini looks something like this (the exact contents will vary based on operating system and which Eclipse package you have):

-startup ../../../plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar --launcher.library ../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.100.v20110502 -product org.eclipse.epp.package.jee.product --launcher.defaultAction openFile -showsplash org.eclipse.platform --launcher.XXMaxPermSize 256m --launcher.defaultAction openFile -vmargs -Dosgi.requiredJavaVersion=1.5 -XX:MaxPermSize=256m -Xms40m -Xmx512m

Among other things, this sets the heap space to 40MB initially and a maximum of 512MB, and also specifies a maximum PermGen size of 256MB. A max heap of 512MB might be OK for some users, but it’s often necessary to bump that value up for large project sets or when some third-party plugins are installed.

Specifying the JVM

One of the most recommended options to use is to specify a specific JVM for Eclipse to run on. Doing this ensures that you are absolutely certain which JVM Eclipse will run in and insulates you from system changes that can alter the «default» JVM for your system. Many a user has been tripped up because they thought they knew what JVM would be used by default, but they thought wrong. eclipse.ini lets you be CERTAIN.

The following examples of eclipse.ini demonstrate correct usage of the -vm option.

Note the format of the -vm option — it is important to be exact:

TODO: I know this next statement is not completely true, I just don’t know the exact answer. A path ending in «bin», pointing to the «bin» directory of the Java distro works, and Ed Merks tells me that pointing to a «shared library» works also.

  • The value must be the full absolute or relative path to the Java executable, not just to the Java home directory.
  • The -vm option must occur after the other Eclipse-specific options (such as -product , —launcher.* , etc), but before the -vmargs option, since everything after -vmargs is passed directly to the JVM.
  • For the 32-bit Eclipse executable (eclipse.exe on Windows) a 32-bit JVM must be used and for the 64-bit Eclipse executable a 64-bit JVM must be used. 32-bit Eclipse will not work with a 64-bit JVM.

Here is an example of what eclipse.ini might look like on a Windows system after you’ve added the -vm argument and increased the maximum heap space:

-startup plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502 -product org.eclipse.epp.package.java.product --launcher.defaultAction openFile --launcher.XXMaxPermSize 256M -showsplash org.eclipse.platform --launcher.XXMaxPermSize 256m --launcher.defaultAction openFile -vm C:\Java\JDK\1.8\bin\javaw.exe -vmargs -Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx1024m

Remember that the exact values will differ slightly depending on operating system and Eclipse package.

-vm value: Windows Example

This is how the -vm argument might look on Windows (your exact path to javaw.exe could be different, of course. Please beware of paths that contain a space, the examples below do not have any spaces, and using quotation marks around paths that contain spaces does not seem to work):

-vm C:\progra~1\Java\jre1.8.0_112\bin\javaw.exe

An alternative way is to insert the following VM option before the -vmargs option in the Eclipse shortcut’s properties (edit the field Target inside the «Shortcut» tab):

-vm C:\jdk1.7.0_21\jre\bin\java.exe

This might not work on all systems. If you encounter «Java was started but returned exit code=1» error while starting the eclipse, modify the -vm argument to point to jvm.dll (exact path could be different):

-vm C:\Development\Java\64bit\jdk1.7.0_09\jre\bin\server\jvm.dll

-vm value: Linux Example

This is how the -vm argument might look on Linux (your exact path to java could be different, of course):

Читайте также:  Php directory file extension

-vm value: macOS Example

On a macOS system, you can find eclipse.ini by right-clicking (or Ctrl+click) on the Eclipse executable in Finder, choose Show Package Contents, and then locate eclipse.ini in the Eclipse folder under Contents . The path is often: /Applications/Eclipse.app/Contents/Eclipse/eclipse.ini

For versions of Mac OS X 10.7+ is something like:

-vm /Library/Java/JavaVirtualMachines//Contents/Home/bin

For example, the latest JDK 1.8 (as of July 2015) is /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin

For standard Mac Java installations and so you don’t have to continually update the setting when you install new Java VMs, set the -vm flag to simply /usr/bin :

If you want to use another JDK (that has the macOS directory layout, like the .tar.gz from AdoptOpenJDK) you should use:

For JDKs without macOS directory layout see: Using a JDK without macOS directory layout

NOTE: Occasionally, depending on the version of your macOS and whether or not you had already run this particular Eclipse installation before, upon launch after changing the -vm, you may run into an error that says «the application is damaged and can’t be opened». This is the expected behavior since you just modified a signed/notarized app. This problem can be overcome by opening the Eclipse application once before changing the eclipse.ini file. Alternatively, running of the following command can fix the issue too: xattr -cr Eclipse.app

Here is additional information:

Perhaps the best way to determine the location for the JDK you want to use is with the utility

/usr/libexec/java_home --verbose

From the list produced by that command, select the JDK you want to use and put that path into the eclipse.ini file, making sure to append /bin/java to the path (eg, /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java

Note that the full path can either include java or not. For example, the following will both work:

-vm /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin
-vm /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java

Using a JDK without macOS directory layout

If you want to use a JDK that doesn’t follow the macOS directory layout, like the ones installed through SDKMAN!, then you need to specify the path to the libjli.dylib file.

For JDK 11+: /lib/jli/libjli.dylib

For JDK 8: /jre/lib/jli/libjli.dylib

Examples using SDKMAN!

-vm /Users//.sdkman/candidates/java/11.0.8.hs-adpt/lib/jli/libjli.dylib
-vm /Users//.sdkman/candidates/java/8.0.265.hs-adpt/jre/lib/jli/libjli.dylib

NOTE: Beware that if you use current instead of using a specific JDK version identifier it will use the default if you launch the Eclipse.app using the UI (double-click or using Spotlight). If you launch it from a terminal it will use the one currently selected.

See Also

Источник

Оцените статью