Failed to bundle Java application 1.8 for Mac - java

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.

Related

pyspark 'Unsupported class file major version 55' in Pychrm with anaconda plungin

I'm running s simple pyspark python script in Pycharm, whithin an anaconda env with Python 3.7 (pyspark version 2.4.4) and I got error :
pyspark.sql.utils.IllegalArgumentException: 'Unsupported class file major version 55'.
I've followed the potential solutions I found on stackoverflow but non of them works, I followed this one:
https://stackoverflow.com/a/54704928/12375559: I've added java1.8.0_221 in my system env variables:
but when I type java -version in Pycharm terminal it's still using java11.0.6:
>java -version
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+8-b765.1)
OpenJDK 64-Bit Server VM (build 11.0.6+8-b765.1, mixed mode)
Then I found this:
Pyspark throws IllegalArgumentException: 'Unsupported class file major version 55' when trying to use udf switch boot jdk of Pycharm (2xshift -> jdk -> select jdk 1.8)
So I navigated to Pycharm Switch IDE Boot JDK:
I can see the second option is 1.8 but without anaconda plugin, so I'm not sure what to do now because I don't want to mess up with my settings, might someone be able to help me please? Many thanks!
The 55 error is caused by an older Java version trying to execute Java version 11 code (in a .jar or .class file). So it seems like an older Java version (for example Java 8 (a JVM 8)) is used, but it encounters a part compiled in Java 11 (see 55 is Java 11).
Since Java 8 is less well supported, you could try to use Java 11 or newer (see Java version history). You could try to use PySpark 3.0.1 with Python 3.8 and Java 11. That way, you have recent parts that should be able to work together.
These links might also be helpful:
Specify Java version in a Conda environment
Spark Error - Unsupported class file major version

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.

how can I find JRE version of running application in Linux server

I am getting below result, Does it mean I am having JDK 1.7.0_45 and JRE is 1.42 ? Please advise.
$ javac -version
Eclipse Java Compiler v_677_R32x, 3.2.1 release, Copyright IBM Corp 2000, 2006. All rights reserved.
$ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
$ alternatives --config java
There is 1 program that provides 'java'.
Selection Command
-----------------------------------------------
*+ 1 **/usr/lib/jvm/jre-1.4.2-gcj/bin/java**
Enter to keep the current selection[+], or type selection number:
It would appear that you have two versions of Java installed:
The Java on your PATH is Java 1.7.0. I think it is an Oracle build rather than a build from your Linux system's package repository.
The Java configured using alternatives looks like a GCJ Java that is compatible with Java 1.4.2. It was probably installed from your package repository. IMO, it is inadvisable to use this from a technical standpoint. In fact, I would recommend uninstalling it.
Actually I am getting "Unsupported major.minor version 51.0" error after uploading a external jar file to Informatica powercenter Java transformation.
That implies that Informatica is using the Java 1.4.2 installation.
Now, the version of Java that an application uses will depend on what version of Java the application's launcher / launch script is using. That could depend on a number of things:
If the launcher uses an absolute path for the java command, then that is what will use.
If the launcher uses a simple name (e.g. java) then the version used will depend on the launcher's $PATH. This is probably what is happening ... and the $PATH used is different from your shell's $PATH.
So what is the solution?
You could add the Oracle Java install to the alternatives system. See man alternatives or Google for instructions using "java oracle alternatives install"
You could tweak the $PATH used by the application's launcher.
Depending on your Linux distro, you could install an OpenJDK 1.7.0 JDK or JRE from the package repos. That will (should) add the new installed Java to the alternatives database, so that you can select it instead of the old GCJ 1.4.2 installation.

Eclipse windowbuilder java 1.6 1.7

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.

How to uninstall newer version of java and install older version?

java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)
Now I have a Java application which says
A different version of Java Runtime Environment (JRE) is required to use this application.
and it is 1.6.0_17...
What to do?
It's really strange that the software you are trying to run requires a very specific update release (such as Oracle Java 6 update 17). Update releases are compatible and there should not be a need to require a very specific release.
On this page you can download earlier versions of Oracle's Java implementation, including Java 6 update 17.
if you really want to have different version of the application running, then the keyword java needs to be fully provided with a path.
one good way is to export the java_home before you run the application and have the application always read the java home when starting the server.
export JAVA_HOME = c:\jdk7
JAVA_HOME/bin/java -server ...
export JAVA_HOME = c:\jdk6
You have to uninstall your current version of java and install the desired version.
You can found all previous version of java on this (Java Older versions) location.
If you are using windows you can directly uninstall and install the older version.
Note: we can use multiple versions in a system by changing the system or user environment variable to use some version as my current java version make or put the path as followed it should be pasted first in path
C:\Program Files\Java\jdk1.7.0_12\bin;.;
[;.;] this will indicate as current working directory and this version will only take as default version while installing java dependent sofware installations ex:netbeans,tomcat etc

Categories