Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 10 days ago.
Improve this question
I haven't found an answer yet fitting a knucklehead such as me, so I'll ask for myself : I'm on macOS 13.1 and I have openJDK 19.0.2 installed already ; how am I supposed to install JavaFX ? The only downloads there just spit out a folder, which I have no idea what to do with.
There are no installation instructions that I could find, the site juste says that "The JavaFX runtime is available as a platform-specific SDK, [and] as a number of jmods" which isn't very useful if you have no idea what a jmod even is. What am I supposed to do ?
I don't know if that makes any difference, but I'm trying to install the runtime part of it I guess. I need to run a thing, not code with the library. I don't even know if there's a difference in the Java world though ?
JavaFX is implemented as open-source in the OpenJFX sub-project on the OpenJDK project. OpenJFX is led by the Gluon company, in cooperation with Oracle Corp.
OpenJFX is simply a few libraries, a collection of Java JAR files. You need to obtain a copy of the libraries, and make them available to your app. You can do this in one of three ways:
Install a copy of the libraries as part of your app.
Install a copy of the libraries in a place that will appear on the Classpath of your app. For example, on macOS: /Library/Java/Extensions.
Install a JDK that comes bundled with the libraries. I know of two vendors that make an edition of their JDK products to include the libraries: ZuluFX by Azul Systems, and LibericaFX by BellSoft.
By “install” I mean simply making the JAR files available: (1) download, (2) move to the right folder location. There is no need to run an installer app. There is simply not anything complicated enough about this to require an installer.
👉 The last of those three (a JDK with libraries bundled) is the easiest if you are new to programming.
If you will be doing serious work with Java and JavaFX, I strongly recommend learning to use a dependency management tool such as Apache Maven or Apache Gradle. Such a tool automates the chore of locating, downloading, and installing libraries such as OpenJFX.
I found how to do it, so here's a guide :
Download the JDK for your java version from JavaFX
Open /Library/Java/JavaVirtualMachines/openjdk.jdk/Contents/Home
Move everything from the lib and legal folders you downloaded to the respective subfolders where we just opened
Delete jrt-fs.jar
Run your program with java --module-path $JAVA_HOME/lib --add-modules javafx.controls -jar Program_Name_Here.jar
Bonus: If you don't want to have to type out that command every time, run :
echo _JAVA_OPTIONS="--module-path=$JAVA_HOME/lib --add-modules=ALL-MODULE-PATH" >> ~/.bash_profile
in your terminal. The modules will all be loaded by default when running java programs (I have no idea if there are any side effects, I don't understand anything about Java).
Please note that the program still won't work when double-clicking it directly, because of java magic or something.
Related
I have a NetBeans Platform application (8.0.2 if it matters) with bundled JVM and Installers (Windows only) generated using maven, specifically nbm-maven-plugin:build-installers. It has quite a bit of customization, but effectively it has jre.zip in it, which is extracted into jre folder as part of the installation and then used by the application as embedded java, by virtue of having jdkhome="./jre" in its conf file. Everything works as expected, but when you run installer itself it does require java to be present on the host, if it's not there you see "JDK 7 is required for installing ... Make sure that the JDK is properly installed ...".
I've found all the discussions around it referencing each other, e.g. https://blogs.oracle.com/geertjan/entry/installing_the_jre_via_an but they're all using ant and not maven. The ones talking about maven don't have much useful information. What am I missing? I'm sure it's simple enough, but I can't find an answer anywhere (. I'm sure I'm not the first one to hit this, help me please! Which , .conf parameters, template.xml sections are required? I already have jre both as zip and as self extracting exe as suggested in the blog above, but have no idea how to make it work.
Thank you very much for any ideas.
I want to write my first JavaFX 8 application (doing my first experiments with e(fx)clipse, etc.) and have a few concerns about platform independence.
JavaFX 8 is a part of the Oracle JRE, which is the most used JRE on Windows. Therefore, I do not really bother here, since JavaFX will be installed on nearly every Windows machine running Java 8.
But on Ubuntu and other *nix, OpenJDK is often used as Java distribution. Since openjfx is separated from open-jdk-8-*, many will not have JavaFX installed by default.
I thought of:
Writing an install script that calls sudo apt-get install openjfx (which I would like to avoid, since I would like the executable .jar to be runable on its own, without script)
Shipping a JavaFX distribution (i.e., its .jars) with my applications (but I read that this should not be done)
Both ideas do not seem very promising...
Since I hope that there are some JavaFX pros out there, i hope that someone can help me with "What are the best possibilities to ensure that my JavaFX application will run fine, both on Windows and Ubuntu?" What are state-of-the-art techniques on how to tackle this problem?
This page (http://www.sj-vs.net/creating-a-simple-debian-deb-package-based-on-a-directory-structure/) describes very well how to build a simple .deb package based on any directory structure (e.g., with precompiled stuff).
You can than add your dependencies, e.g., to javafx packages, to the Depends section of the control file. (https://www.debian.org/doc/debian-policy/ch-relationships.html). This forces any installer like apt or dpkg to install javafx together with your package and makes them fail if this package is not available. You can also add a postinst script that will be executed after the installation in which you can set classpaths etc if necessary.
I have a Java desktop app that runs on both the MacOS and Windows.
I understand that I cannot have one distribution for each, which is not a requirement.
I need to know what tool or tools is best to use when delivering a Java app for each.
The tool should install prerequisites (in this case, Java and some JARs) and look native to the respective operating system.
As for OS X's java situation:
Currently, JDK 6 is bundled in the OS.
Presumably, the next version of the OS will still include JDK 6.
It's publicly stated that the OS will have a well-defined place to install multiple copies of Java runtimes, a public interface choosing which of the Java version, etc. See here.
Apple started contributing back its own code to the open JDK community, so JDK 7 should be available as a separate download, see here.
So, you're not expected to include Java runtime itself into your Java app even then. You're not supposed to install Java in a ramdom place on a filesystem, for example.
As for how you should deploy java apps on OS X:
Double-clicking jar just works.
However, that won't be pretty, because you would only have a generic Java icon in the Dock. You don't want that.
You should use Jar Bundler to make it an honest OS X app. On Mac, it comes with XCode. See the documentation here. You can do that on a non-Mac machine too, using this open-source project.
On Windows, I would recommend either JSmooth or WinRun4J.
On a Mac, the situation is a bit more complex (as the comments point out), but just distributing an executable JAR is probably good enough for now.
I just installed http://yacy.net/
It advertises as easy install except that when I run it says cannot find javaw which spoils nearly everything.
If I were to distribute a java app myself I'd like not to have user knows anything about downloading and installing java, so any article, tool which explains how to package a java app professionally like one can do with a windows app easily ?
There are several approaches to this, all of which have their own set of drawbacks. Here are some of the most popular:
Bundle a private JRE with your application. See the README file that comes with your JRE for the details.
Use a launcher (such as launch4j) that can download a JRE at runtime if a suitable one is not found on the target machine.
Compile Java to native, then distribute as a regular Win32/Linux executable. You can do this with Excelsior JET.
Since you are concerned with deployment, you'll probably also want to create an installer for your application. There are dozens of options for this, such as NSIS.
I need to build an installer that does the following:
Installs my jar on the client.
Auto-detects if JRE is installed (in which case it does not re-install it), otherwise installs it without the user clicking on another button.
Auto-starts the application when the client is booted.
Works across Windows, Mac and Linux.
Any idea how to go about it?
If a commercial tool is ok, I can recommend install4j. 1, 2 and 4 are easy to do with it, but about 3 I'm not sure. Edit: You could probably achieve that by installing your app as a "service", which install4j supports for all platforms. Quoting from its Features page:
install4j offers full support for
generating and installing services
(daemons). For services, install4j
generates service executables on
Windows, startup items on Mac OS X and
start/stop scripts on Unix/Linux
platforms.
Edit: Regarding #2, JRE detection: install4 has pretty nice, flexible options for JRE bundling/detecting. You can include a JRE (statically or dynamically, shared or not) or prefer to use one already present, with the possibility to download a JRE from within your installer as a fallback. Check these docs for more: How Installers Find a JRE and JRE Bundles.
(More about my experiences with install4j.)
For other tools, you could check some of the earlier Java installer questions on SO:
What’s the best way to distribute Java applications?
Java Application Installers
What is the best installation tool for java?
Commercial tools like InstallAnywhere can do that. After installing the JAR (and links and such), installers can check the registry if Java is already installed and proceed or not. As long as the installer supports all needed plattforms, you are fine.
You could use launch4j , it does not automatically install java however. But maybe there's a way to make that work by packaging the JRE for example.
You may also want to take a look at BitRock InstallBuilder, it provides built-in functionality to perform what you want. We will be happy to build a sample installer for you, just drop us a line.
I recommend downloading the source code for the build scripts of popular Java programs like limewire and follow their example. The end.
...Or you can do like I did:
I have done the JRE detection and
download/install of redistributable if required with
NSIS on Windows. Maybe an .msi is better than a installer.exe which NSIS creates. I believe msi are more like packages on mac so they allow proper updates. Maybe NSIS creates MSIs... not sure.
Mac is simply an Java App
bundle and you specify the JRE and other Java info in the
info.plist and you can optionally create a .pkg
file to give the user an installer and bundle up in a dmg using the command line dmg programs.
I haven't done Linux and don't plan to... sorry :)
All this was a fair chunk of work. I first did the Windows stuff then a couple years later did the Mac stuff.
You can integrate all of this in NSIS build scripts and Ant. I can't remember why I didn't use install4j. Probably I was too cheap :)
Haven't heard of anything that works across all those platforms, but JSmooth might help (fits your needs on Windows). I've used it about 2 years ago and it worked fine.