So I installed at centos 6.4 openjdk 8, netbeans 8 and build openjfx. The only thing I can't uderstand is how to make netbeans work with built openjfx sdk. As openjdx sdk is in folder /temp while jdk is in /usr/lib/jvm/java-8... I can't undertand how to add openjfx to netbeans as everywhere people say that jfx is already in jdk.
So, what now should I do to make all these work together?
It's easiest just to use the Oracle JDK if you can do that. You could possibly hack something together by installing the Oracle JDK, seeing where in the JavaFX code is placed in the Oracle JDK and copying the OpenJFX build artifacts you created to similar locations in the OpenJDK, then pointing your NetBeans at the integrated OpenJDK/OpenJFX install. Seems a lot of a work for a development environment though when you could just use Oracle JDK and it would just work out of the box. You could always switch to OpenJDK/OpenJFX for final packaging for customer delivery once your development is completed.
Ubuntu has binary OpenJFX packages available, so if you could switch to Ubuntu, you should be able to use them (I've never tried it).
I am not aware that anybody has created anything similar for CentOS (this may change in the future). If you stick with CentOS, you would probably need to follow my earlier advice of manually copying JavaFX files into the OpenJDK structure at the locations that NetBeans expects. Usually the files you will need to worry about are the jfxrt.jar file (see What's the location of the JavaFX runtime JAR file, jfxrt.jar, on Linux?) and the associated binary libraries (which must be in the correct location to be found), though there are possibly other files such as property files or javafx swt integration libraries that might be needed for correct function.
See related question:
JavaFX and OpenJDK
Related
For years I have distributed a piece of software that relies on javafx, and the solution has been to include a JRE in the distributed software and run my .jar file with a script that sets JAVA_HOME. It has worked great.
The Mac version has always been a challenge: I have to download the .dmg from java, unpack it, and tweak the script for (historically) a different directory structure (which may be an artifact of the .dmg packaging, I don't know). But it always worked. (I do this on Linux.)
I recently updated the included JRE to the latest version (1.8.0_291) and it no longer works on the Mac, even after I corrected for the new directory structure. Users report that the script errors with:
Error: could not find libjava.dylib
Error: Could not find Java SE Runtime Environment.
...and indeed, there is no libjava.dylib. In the previous Mac JRE version I was using (1.8.0_92) this file was at:
lib/jre/Contents/Home/lib/libjava.dylib
...but it is not present anywhere in the latest. I also note that the latest JRE totals 107 MB, where the older one was 164 MB, so it would appear that there is something I'm not understanding about these more recent JRE downloads. E.g. perhaps the mac version requires an installer to run to be complete?
Where can I download a distributable Mac JRE?
Failing that, what is the proper way to make a contained Mac JRE?
It appears that AdoptOpenJDK is a good general way to go for multi-platform pre-built JREs, but they do not include JavaFX.
I attempted to use OpenJDK in conjunction with libraries from OpenJFX from openjfx.io, and although my application superficially worked, there were very many exceptions implying poor compatibility between the two. (I was unable to match versions precisely for JDK 11. It's possible that the latest version of both (JDK 16) might interoperate better.)
I found the Liberica JDK from BellSoft. Their "Full JRE" includes javafx and is working. I do get one swing-related exception on startup, but it doesn't seem to matter to functionality.
Apparently there is also the Azul platform, but I have not investigated it.
I am getting an error when trying to run a .java file as a Java Application and I get the following error:
Unbound classpath container: 'JRE System Library [JavaSE-14]' in project <project_name>
I tried to change the execution environment and for JavaSE12 and later versions there are no compatible JREs. (But for JavaSE11 the compatible JRE is java-11-openjdk-amd64)
I do not know what to do because the project I am working on doesn't work with old Java versions. How can I choose an environment for the latest Java versions?
Note: I am using Ubuntu 20.04 if that makes any difference.
tl;dr
I am not a Linux user, so I may not know best. But I suspect the simplest approach to running your .java file is to:
Obtain and install a JDK for Java 15 for Linux
Call java app on the command-line, passing the path to your .java file.
Backwards-compatibility is a priority for the Java team. Most any existing Java app should be able to run with the latest version of Java. There are exceptions, but they are very few.
JRE is passé
The JRE (Java Runtime Environment) was a subset of the JDK (Java Development Kit), omitting some of the programmer tools. The JRE as a separate product seems to be getting phased out.
Oracle and much of the Java community has shifted away from the idea of regular users having Java installed on their personal computers. Instead, apps should be delivered with a JVM specific to their host platform bundled within the app. This bundling of a JVM can be done using newer tools such as jlink and jpackage.
For more info, read:
Java Client Roadmap Update - Oracle (2020-05)
Java is still Free
Obtain a JDK
You said you have a .java file to execute. That file must first be compiled before it can be executed. The more recent versions of the java app can do both steps at the same time, compile & execute.
First download and install a JVM for your host platform.
Java 11 is the current long-term support (LTS) version. Java 15 is the latest release. You may want to read about the six-month release cadence for Java.
You have a bounty of vendor choices providing implementations of Java. Here is a graphic flowchart I made to assist in choosing a vendor.
If the steps shown here are overwhelming, I suggest either:
Using apt-get or similar package installer to obtain a build of OpenJDK for Ubuntu. I am not a Linux-user, so I do not know the details.
Head over to AdoptOpenJDK to download an installer for Linux.
Some motivations to consider in selecting a vendor.
Compile & run your app
Once your JDK is installed, on a console (such as Terminal.app in macOS), run something like the following. The java command should both compile and execute your .java file, if that single file makes up your entire app.
java /path/to/some/folder/MyJavaApp.java
I am just interested, as far as I know if you want do some Java programming, you will need to download a JDK. As part of the JDK, it comes with the JRE. However, I think most Windows OS has pre-installed JRE already. I have several questions:
Does this mean this pre-installed version will get overwritten by the freshly downloaded and installed JRE?
Does a JRE have a version e.g. JRE-7,JRE-8?
If there is version for the JRE and the pre-installed JRE gets overwritten, does that mean there is a risk that some old applications will not work anymore?
1) This depends on your installation directory choice.
2) JRE is just a runtime part of the JDK (no compilers and tools) and thus is has the same versioning scheme as JDK.
3) Java is developed in the way that guarantees backwards compatibility. However you can get incompatibility problems with tools like Maven or libraries like JAXB.
Go to the Windows control panel, click Java, click the Java tab and then View. You will see all of the versions of Java that have been installed.
I am putting together my first Java package for distribution to users, and am running into some difficulties. I have jar packages that I've built that users can't run; the error messages vary, but are all "version" something or another. I suspect I'm selecting the wrong build paths, and I'm not quite sure where to start troubleshooting because I don't clearly understand the differences between the Java executable (javaw.exe), the JDK and the JRE; I have some questions that I'd like answered which will help in that understanding. I'm used to the way that C# executables compile in VS; wrapping my head around how executable jar files come together is still a little mysterious to me.
Although I've done a few google searches, most of what I'm finding is how to build a jar file, but not how to manipulate/use/select the Java, JRE and JDK versions appropriately to ensure compatibility. I do understand that the JRE includes the virtual machine that allows Java bytecode to run anywhere, and that the JDK includes development tools...but as to figuring out which version I AM running, vs which version is used when building jar files and which version SHOULD be used...I am completely lost.
I'm using Eclipse Indigo under 64-bit Win7. My build path includes the following:
JRE System Library: C:\Program Files\java\jre7\*
External paths: C:\<MyDocuments>\java\lib\commons-io-2.4*
I also have, installed on my machine, the following paths which are NOT included in the build:
C:\Program Files (x86)\java\jre7\
C:\Program Files (x86)\java\jre1.5.0_22\
C:\Program Files (x86)\java\jdk1.7.0_21\
The users that will be running this executable file are only supported (by corporate IT) up to JRE5. I suspect that my building this pointing it jre7 is one of the things that's messing with me.
My first stupid question is whether there's a difference between "Java" and the "JRE" when it comes to version numbers. For instance, when I read about JavaSE7 or JavaEE7, are they talking about the JRE version for the standard or enterprise editions? Are the development kits and runtime environments just components to JavaSE/EE? Or are they separate and distinct products?
Then, my understanding is that I should build this jar using the lowest-common-denominator JRE expected from my users. In this particular case, because the corporate standard is JRE5, I should build this pointing to JRE5 instead of JRE7. Is that a correct assumption?
Does it matter if I build using the 64bit or 32bit version? Some older machines may still be 32bit running JRE5, so I need to make sure I'm backwards compatible.
The Program Files (x86) naming conventions confuse me. JRE7 installed as \jre7. However, JRE5 installed as \jre1.5.0_22, and I also have jdk1.7.0_21, which, based on the JRE name, I assume to be the Java7 Development Kit. Do I need to install the Java5 Development Kit to properly build this program? And am I properly interpreting the versions from the filenames? that 1.5 represents Java5 and 1.7 represents Java7?
Then, my last question I know there's an Eclipse option to copy the external libraries to the project. I assume that if I do this, this will be included with the jar so the users do NOT need to have the Apache Commons jars on their local machines in order for this to run properly. Does the manifest include any confirmations that these files were included? I've been unable to find any references...so I'm trying to verify if I'm even pulling the Commons libraries over and where to look to get that confirmation.
This is just speculation, but I think you may have to re-write the program with the java5 jdk, because some of the APIs/libraries used in java7's jdk may not be recognized by the java5 jre. (Just like it wouldn't be possible to play PS4 games on a PS2... without any serious modding)
If you write the program in Eclipse, you can just select what library you want to use as you create the Java project. At the "Create a Java Project" screen, you can select the "Use an execution environment JRE:" or "Use a project specific JRE" or "Use default JRE" option. (I have jdk6 and jdk7 installed on my computer so I'm able to select those two options; which is why you may have install the jdk5 in order to create a java 5 project.)
You are properly interpreting the filenames. jre1.5.0_22 is java 5 update 22.
There is a way to specify which JRE is used to run the jar file.
cmd prompt >
"C:\Program Files (x86)\java\jre1.5.0_22\bin\javaw.exe" -jar "filepath_filename.jar"
Drop the "w" from the javaw.exe, and you'll be able to see any console and/or stack trace output.
I have developed a Java Application in Eclipse using JDK 1.7.0, the application runs and everything works as expected.
Now I would like to send the application to a colleague of mine who is using a different version of the JDK. He is using 1.6.x.
I am not interested in him opening up the application and debugging through it in Eclipse. I would only like him to run it. If I make a runnable .jar of the application and send that to him, would it work even though he has a different JDK installed on his machine?
Thank You.
You need to compile it using JDK 1.6 (or lower). Provided your code doesn't use features from Java 7, you won't have to change anything in your sources
It would work if your colleague had a newer JRE than the JDK you used to compile it. All versions of JRE are backwards-compatible with all class files built with previous versions, but the opposite can clearly not work because new versions introduce new features. Your colleague will get an UnsupportedClassVersionError.
However, it is easy to set up in Eclipse the target class version for your project: go to Project Properties, Java Compiler, and under JDK Compliance choose the version 1.6.
Needless to say, this will fail if your source code uses any features or library calls which the version 6 does not support.