How to start eclipse with different version of Java? - java

I have here a computer (Windows XP) with java 1.4 and java 1.6 (I don't know why there is 1.4 on this system, probably they forget to uninstall it). Here is also Eclipse Helios.
Now if I want to start eclipse I get the message that Java 1.4 is too old. Huh? I have here also 1.6, Eclipse should start with 1.6
I checked the current Java Home via cmd
java -version
java version "1.4.2_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_0
Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)
Ok so somehow 1.4 is the standard java here. Fine, let's change standard java to 1.6 (because it's installed, so it should work). But wait, this is not working I don't have the rights to change that. Cannot change any standard java path. So what can I do? I figured out, that I can bypass the Eclipse message if I edit eclipse.ini the line -Dosgi.requiredJavaVersion=1.4 to -Dosgi.requiredJavaVersion=1.5 But at the end I'm using this eclipse with Java 1.4, and who knows what bugs or problems I'm getting with this. I have the path to java 1.6 , can I use this and start Eclipse, how? Any ideas?

You can add the -vm option to eclipse.ini:
-vm
C:/path/java/jdk1.7.0_03/bin/javaw.exe
It has to be on 2 separate lines and it has to be added before -vmargs.

You can configure it in the build path
Go to Eclipse(mac) / Window(for windows)
->Preferences
->Java
->Installed JREs
->JAdd the jdk/jre library you would like to add.
->click ok (Done)
Then the jdk is configured for the completed eclipse workspace.
You Can change the jdk for the individual project using the build path configuration.
To do that :
Select the project ,right click
->Choose the java Build Path.
->JRight hand side of the pane click the "Add Library"
->Choose "JRE system library"
->Select "Alternate JRE" (There u can see the list of the installed/configured JRE).
->Click Finish
Let know if still the problem exists.

Related

Unable to find JAVA icon in System-Preference or Library of my MAC

I have been a Windows user all my life and have recently got a MAC. My Mac is using MacOS Catalina.
I am trying to set-up JDK and get going on a project, however the issue is after I have installed JDK 11.0.4, I don't see any Java-icon on my system preference nor could I find Java folder in my ~library. However, when I go to terminal and do java -version I do see java being present as below
~ % java -version
java version "11.0.6" 2020-01-14 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.6+8-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.6+8-LTS, mixed mode)
I need help to see how I can resolved this, and then add my java installed location to my .bash_profile
Normally the JDK is located under
/Library/Java/JavaVirtualMachines.
The AdaptOpenJdk for example is located here: /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk
For those of you that are still struggling with it. Here is the thing.
The Java Preferences app was part of Apple Java installation and is not used by Oracle Java. Therefore, OS X releases from Apple that do not include Apple Java will not include Java Preferences.
"What happened to the Java Preferences app in Application -> Utilities?"
Now, after hunting around for a while I have figured the following out:
You won't get JAVA in your Mac's System Preference until you have added JAVA home directory in your bash profile, irrespective of the java version installed
Generally be default Java gets installed in your MacintoshHD
So, open your MacintoshHD & then go to GO option from your Finder
Next click on Go to folder option and type-in ~/Library
Now you will see a Java folder and under that JavaVirtualMachines
You will now have JDK folder of whichever java version installed
Right click on JDK folder and click on info, copy the 'Where' location
Open your bash profile with following command vi .bash_profile
Once in VI editor, insert the following:
export JAVA_HOME=copied Where location from JDK folder followed by /Contents/Home
It should look something like below
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.6.jdk/Contents/Home
Now quit editor by :wq and restart your machine and you will now have JAVA in your system preference.
Hope this helps!!

Netbeans 10 not installing

I'm having issues trying to install NetBean 10 (incubating) on a laptop. I've checked that Java is installed, as well as JDK (jdk1.8.0_191). I've checked that Java is installed correctly by going to the command line and typing "java -version" and it correctly responds
java version "1.8.0_191"
Java(TM)SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
I've checked that the environment varible "JAVA_HOME" is correct (echo %JAVA_HOME%), and that the Path variable is correct.
However when I try installing NetBeans (from the C:\netbeans10\bin\netbeans64.exe) (yes, also double checked the laptop is correctly running Win10 64bit, it is) a logo for netbeans briefly appears, goes away after 1 sec, and nothing else happens.
I've tried downloading a fresh NetBeans, reinstalling Java, rebooting the system, disabled anti-virus, disabled firewall, tried from safe boot, however it just does not install.
Anyone have any ideas on what step I'm missing so that I can get this installed?
Thanks in advance.
A possible caused of your problem is that NetBeans is trying to run using a version of Java that does not exist on your machine. To eliminate this as a possibility:
Locate the file netbeans.conf. It will be in the etc directory within the NetBeans installation directory.
Open the file in any text editor. It is just a properties file containing name/value pairs,
Locate the line containing the text netbeans_jdkhome.
If the line is commented out delete the leading # character.
Set the value to the actual path to your JDK. For example, on my machine it would be: netbeans_jdkhome="C:\Java\jdk1.8.0_191".
Save the file and (re)start NetBeans. NetBeans will now use the JDK specified by the netbeans_jdkhome property.
If NetBeans still doesn't start then update your question with the content of the NetBeans log. See NetBeans - where to find the IDE log? for details on locating that file.
One other point: although you can run NetBeans 10.0 using JDK 8, I can't think of any good reason to do that. Most users will probably download and install JDK 11, and use that instead.

Ecilpse Oxygen.3a Java IDE cannot add window GUI via window builder error opening wizard

I try to use the Eclipse Oxygen v4.7.3a (Oxygen) Java IDE.
I try to use window builder to build a GUI application with Java, but when I try to add the window I have an error message.
I tried to google it, but I cannot even know what that message needs from me.
It says:
problem opening wizard
The selected wizard could not be started.
Plug-in org.eclipse.wb.swing was unable to load class org.eclipse.wb.internal.swing.wizards.application.NewSwingApplicationWizard.
An error occurred while automatically activating bundle org.eclipse.wb.core.java (528).
My java -version output:
OpenJDK version "10" 2018-03-20
OpenJDK Runtime Environment (build 10+46-Ubuntu-5ubuntu1)
OpenJDK 64-Bit Server VM (build 10+46-Ubuntu-5ubuntu1, mixed mode)
I had exactly the same error occur in Eclipse Oxygen.3a on my Mac with Java JDK 10 installed. There is code in WindowBuilder 1.9 that uses a Java feature that was either altered or dropped in Java 10. I was able to resolve the problem by making two changes (they assume that a Java 9 JDK is available on your system; if not, you must install it):
change the Java VM for Eclipse to one in a Java 9 JDK (using the -vm setting in eclipse.ini; see this link for a good post on how to do that)
change the JRE for the project to a Java 9 JRE
The first change is the more important one since Window Builder is a development aid running as part of Eclipse.
I made the project JRE change for my own sanity so I didn't have a mix of Java versions. You may be able to skip that change (I didn't try it).
I still have Java 10 as the default for the system, so you don't have to completely fall back to Java 9 if you install both JDKs. It may take some tweaking to get both Java 9 and 10 installed and have the one you prefer working as the system default.

Eclipse thinks I only have Java 1.6, but when checking java-version in terminal it displays 1.7. Help :)

I just downloaded Eclipse, and it said "Version 1.7 or greater is required" for Java. Then I downloaded Java 1.7 and installed it and all that, and even restarted my computer. When I check my Java version in the terminal, it says Java 1.7, so why can't Eclipse recognize Java 1.7?
Thanks a lot! :)
My question isn't a duplicate of Running Eclipse on Mac - JVM Version 1.7 or greater is required because I installed the entire JDK 7 and my computer recognizes Java 1.7. Right now, I can't even open Eclipse.
EDIT:
current steps I have taken:
1) finding the path (/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home) to java 1.7 with command "/usr/libexec/java_home -v 1.7"
2) pasting this path by adding the following in the eclipse.ini file,
-vm
/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
Error message is still:
Version 1.6.0_65 of the JVM is not suitable for this product. Version: 1.7 or greater is required.
I am sure you must have done this but just in case you haven't can you make sure the environment variable's are set for Java
Have you tried Window -> Preferences -> Java -> Installed JREs?
There you can add (Using the Standard VM option) a JDK (or JRE) by setting the path to the JDK install directory.
right click on
project --> properties --> java compiler
and see the jdk compiler compliance level option set to 1.7 compiler, if not change it to 1.7 or higher
EDIT :-
eclipse by default will take java installation path from %JAVA_HOME% variable, firstly you check whether you have set JAVA_HOME path in your machine.
or you can manually set java path in eclipse.ini file as said in this post
How do I set the Java path in Eclipse so I can run it on an external drive?
and
How to specify jdk path in eclipse.ini on windows 8 when path contains space

Eclipse in OS X uses different version of Java than CLI

When I type java -version in the console I get java version "1.8.0_05". The soft link /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK points to /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents. In the java preferences window, the only listed version of Java is 1.8. JAVA_HOME is set to /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home.
However, when I try to run Eclipse.app, I get the error: Version 1.6.0_65 of the JVM is not suitable for this product. Version: 1.7 or greater required.
I believe it is trying to use /System/Library/Java/JavaVirtualMachines and in that directory the only version is 1.6.0.jdk.
How can I get eclipse to use the correct version of Java?
I solved this issue in my mac with yosemite:
Installed JDK for MACOSX 64bits from https://jdk8.java.net/download.html
Inside the eclipse.ini I put this line:
-vm /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
And it worked for me!
Download the 64-bit version of Eclipse instead of the 32-bit version.
The reason is that Eclipse contains native machine code (for the GUI) which is why there is both a 32-bit and 64-bit version of Eclipse, and this explicitly require the corresponding Java version. Originally Apple created both versions up to Java 6, but Oracle only creates a 64-bit version (much to the dismay of owners of older machines). So, if you download a 32-bit version of Eclipse it will only run with an Apple JVM, which apparently is too old (which surprise me - I thought Java 6 was still supported for Eclipse 4.4)
I faced this same problem but rather than making it to use version 1.8 I changed the settings in eclipse.ini file so I can just run the program regardless which version of jvm does it want to use
Solution:
Open the directory where you have Eclipse copy in your computer.
You would see a file name eclipse press control key and click on it to see the options.
Then click on Show Originalfrom the options, there you would find eclipse.ini file open it with a text editor and change the -Dosgi.requiredJavaVersion=1.7 to -Dosgi.requiredJavaVersion=1.6
Save the file and open the ecplise.app it should open now without any error
Try adding the following lines to your eclipse.ini:
-vm
/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home
Maybe a newer version of eclipse could help, too (if yours is out of date).
Take a look in your System Preferences -> Java. It should open the Java Control Panel. In the panel, check if you have one (or many) JDKs.
I suspect you have many and are setting the JDK in your .profile while Eclipse is reading some other Java Home.
You can change them manually by running this in your terminal
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
To check if it worked, run java -version and you should see something like
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
Try calling Eclipse now from the command line. To call Eclipse as an App, just set the Java8 through the Java Control Panel. This will be read when Eclipse starts.
This is what I have on my Java Control Panel:
This is on my Eclipse Luna:
Download the 64-bit version of Eclipse.
This solved the problem. Thanks everyone.

Categories