Eclipse windowbuilder java 1.6 1.7 - java

I have just installed WindowBuilder for Eclipse and java 1.7 JDK, but when I create a new JFrame in Eclipse, and try to open the "design-view" in WindowBuilder I get the following error:
"Eclipse is running under 1.6, but the Java project has a 1.7 Java compliance level, so WindowBuilder will not be able to load classes from the project. Use a lower level of Java for the project, or run Eclipse using a newer Java version."
When I check the properties for the project, it is set to Java Compiler 1.7. When I run a Java -version in my terminal I get:
java version "1.7.0_15"
Java(TM) SE Runtime Environment (build 1.7.0_15-b03)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
I have tried to chance the path to the newest Java, following this link:
Link to Eclipse Wiki
When changing it to:
-vm
/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home/bin/java
I get a error when I try to open Eclipse saying:
"the jvm shared library does not contain the jni_createjavavm symbol"
What's where I am stuck. Anyone how knows how to fix this problem? I have tried using Netbeans, but my Mac and Netbeans are not best friends: Pic of screen-crash

Go to Project Properties and change the project compliance level from 1.7 to 1.6. Also leave the Eclipse running under Java 1.6.

In my case I Change my default java version in my whole OS, I followed the steps in this question!, I am using Debian but you can look for you OS how to make java 1.7 the default java version, in my case I do not need java 1.6 anymore and I set my OS java default version from 1.6 to 1.7 it made eclipse load under my default java version 1.7 and then I changed in Eclipse to all workspace the java to version 1.7.
By doing this eclipse will run with default java version 1.7 of the OS.
But if you still need java 1.6 for the OS and 1.7 just for eclipse, in my case using Debian you need to edit:
vim /etc/eclipse.ini
And following suggestion adding the option "-vm /usr/lib/jvm/java-7-openjdk-amd64/bin/"
Of course you need to know your java 1.7 path, it is an example using my path.
It's up to you to choose any solution by OS to load eclipse from he java version of the OS or changing the eclipse.ini to java 1.7 and leaving java 1.6 as default for OS.

Related

File has been compiled by a more recent version of the Java Runtime error SceneBuilder

I've used JLink + JPackage to build a JavaFX app into a self-contained application. I'm using JDK 14. However, when I try to open one of my FXML files in IntelliJ's Scenebuilder I get this error:
File has been compiled by a more recent version of the Java Runtime (class file version 58.0), this version of the Java Runtime only recognizes class file versions up to 55.0.
To run the app in development environment, I use mvn clean javafx:run.
When I check in the IDE's compiler settings, the JDK is correctly set to 14, and so is the JAVA_HOME variable, as shown below. How do I fix this?
PS C:\dev> java --version
openjdk 14.0.2 2020-07-14
OpenJDK Runtime Environment (build 14.0.2+12-46)
OpenJDK 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)
I'd say the problem are your custom components. You have probably compiled them with Java 14 and put the resulting jars into SceneBuilder. So each time when you load an FXML file which uses one of these components you will get that error message because the class file version of your components is younger than the version of SceneBuilder itself. For compatibility reasons it would be a good idea to compile your components with a target 11 anyway. You can do that with your Java 14 compiler. This would increase compatibility in general and solve your problem at hand.
I think (I'm not 100% sure but it makes sense) there are 2 answer's to this...
Your intellij is using an older version of java (It can range from 6 to 13). So you would need to allow intellij to use a newer version of java (JDK14).
Build your application with older version of java, of course you might need to change some functions because of older version of java.

Different java versions on mac machine?

There is something going wrong with my java configuration and it is really bugging me. I am using IntelliJ IDEA and after downloading and installing java 8 I tried to configure my project to use that SDK but I could only locate version 1.6 under /Library/Java/JavaVirtualMachines/. I am new to OS X and I am really confused with the paths.
Looking on my Java control panel I can see I got installed Java 8 but after running java -version on the terminal I get 1.6.0_65.
And the which java gives back /usr/bin/java.
Please help I am completely lost
Here is an example with several Java versions installed side-by-side ...
ls /Library/Java/JavaVirtualMachines/
jdk1.7.0_25.jdk jdk1.7.0_72.jdk jdk1.8.0_05.jdk jdk1.8.0_25.jdk
User can edit ~/.profile to point explicitly at one
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_72.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
And here is result ...
java -version
java version "1.7.0_72"
Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)
Well something was wrong with the installation. I completely removed the other versions (not 1.6) and reinstalled 1.8 using the default path (as there is no option to change it during installation. Now IntelliJ can see JDK 1.8
Thanks for the help anyway

Failed to bundle Java application 1.8 for Mac

I am trying to export my Java Application to Mac. The application is based on Compiler Complience Level 1.7. I tried different methods to bundle the application.
1) Eclipse. The latest version of JVM that I can use to export on Eclipse is 1.6*.
2) Maven. It looks like on Maven also the same problem exists. As when I used following command it showed a version related error.
System:
~Jack$ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode).
Maven method
Maven Command
mvn package osxappbundle:bundle -DmainClass=com.example.Main
Errors that Maven returns
type javax.swing.JList does not take parameters
and
cannot access org.json.JSONArray
bad class file: org/json/JSONArray.class(org/json:JSONArray.class)
class file has wrong version 52.0, should be 50.0
*I know these errors are related to the version of Java. My compiler is 1.7 but when I use maven to bundle it, above errors will be shown.
Eclipse method
Version: Luna Service Release 1a (4.4.1)
What should I do? I could find other alternatives like JarBundler but did not work.
There are two different kinds of Java app bundle on OSX. The older kind works with Apple Java versions (up to Java 6) and the newer kind with Oracle Java (7 and later). The maven osxappbundle plugin only supports the former, which is why it won't use Java later than 6. I presume the eclipse tool you're using is the same.
This alternative Maven plugin claims to work with Oracle Java versions.
The new recommended way to create Java application bundles in OS X is to use Oracle's appbundler. This is Ant-based.
There is also a fork which provides some extra functionality.

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.

How to program with Java 1.6 in a Mac?

I was working in a Java 1.6 project in Windows, and now I have to work from my laptop, that is a Macbook Pro (Intel Core 2 Duo) with a MacOsX Leopard 10.5.8 installed.
In the same laptop I've worked in the past with Java 1.5 with any problems, but now I can't work with 1.6, and I don't know what I'm doing wrong.
When in a terminal I write: java -version I get java version "1.6.0_26"
But when I'm trying to install last version of Netbeans (7.0.1) I get the message:
It's not possibe to install NetBeans 7.0.1 in this volume. This
software can be installed and work only with Java 6
Then I tried to work with Eclipse. I've download last version of the IDE, and open the project. I get some compile errors (the parts of Java 1.6).
I went to Preferences -> Java -> Compiler->Compiler compliance level from 1.5 to 1.6
Then I get a message that says:
When selecting 1.6 compliance, make sure to have a compatible JRE
installed and activated (currently 1.5) Configure
But when I try to change to 1.6
The selected JRE does not support the current compiler compliance
level of 1.6
What I have to do to work with Java 1.6?
EDIT:
I've noticed that at
/System/Library/Frameworks/JavaVM.framework/Versions/
1.6 seems not to be installed
On OS X Leopard (10.5) the JDK 1.6 can only be used on 64bit-hardware (also in the Apple FAQ). If you are on a 32bit-hardware, you will not be able to run Java 1.6.
If you are on 64bit hardware, you can install it via SoftwareUpdate or via the Developer Tools. To select the running version of Java you can use the Java Preferences.
Here you will find a chart which (Apple)-JDK is running under which OS X version.
There is an "unofficial" port I have not tried: The project SoyLatte brings JDK 1.6 to OS X 10.4. and later - perhaps you can have a try with this.

Categories