JavaFX on Linux - linux

What is the situation with JavaFX on Linux (x86 and x64)?
Can a JavaFX app be executed without problems on Linux OS?
I have found some questions from years 2011 and 2012, when apps were not stable!

The current version of JFX released is 2.2.4 and it is quite stable on Linux. However, it will become very much better when Java 8 would be released as it would contain JFX 8 distibution. You can try it yourself now using java 8 early access builds.

JavaFX 8 runs fine on Linux in my experience, the only requirement appears to be libgtk 2.18+. There are full details on Oracle JDK 8 and JRE 8 Certified System Configurations. Working Linux versions include:
Ubuntu 10.04 (and possibly earlier, 10.04 had libgtk 2.20)
Redhat 6
Possible problems you may encounter
3D scene support - requires specific modern GPUs + recent drivers, note there is no software rendering fallback for this, and no plans to - see mailing list question
Video playback requires certain version of libavcodec
OpenJDK does not yet include javafx, only the oracle distribution. Update July 2016 - openjfx package now available .on Ubuntu 16.04...

Javafx runs on JVM(Java Virtual Machine) like all other java applications. It doesn't matter whether you run the javafx application on windows or linux or mac there is no doubt that it will not run. That's why java is called platform independent language. Now stable version of javafx 8 has been released with more features.

Related

Direct3D Static Linking

Is there any way to statically link Direct3D so the program doesn't depend on any D3D DLLs? It seems impossible with Direct3D 9 and later (although I would like to be proven wrong), but I can't find any information on older versions. I'm making a small simple game and I really don't want a mandatory installer, but I want to use Direct3D.
No, there was never a time when you could statically link any version of Direct3D into your app. The same is true for OpenGL.
If what you are asking is "How do I create a Direct3D app that doesn't require an installer?", then this is actually quite easy to achieve as long as you give up on trying to support ancient and irrelevant versions of the Windows OS.
The simplest thing to do is target DirectX 11.0. Your system requirements would read:
Windows 8.1, Windows 8.0, Windows 7, Windows Vista Service Pack 2 with KB 971644
See Direct3D 11 Deployment for Game Developers
Use Direct3D 11.0 APIs
Use DirectXMath, DirectX Tool Kit, DirectXTex, and/or DirectXMesh which are all statically linked
If desired, you could use Effects 11 as it is also statically linked.
Avoid all use of D3DX9, D3DX10, and D3DX11
Use XInput 9.1.0; avoid XInput 1.3 (on Windows 8.0+ you could use XInput 1.4)
Avoid use of XAudio2.7 (On Windows 8.0+ you could use XAudio 2.8)
Avoid use of XACT
If you use VS 2010 or later, then you can deploy the required VCREDIST files side-by-side with your application with a simple copy
If you use the Windows 8.x SDK version of D3DCompile, you can deploy it side-by-side with your application with a simple copy.
Audio is the biggest challenge here since XAudio 2.8 is only on Windows 8.0 or later, and XAudio 2.7 requires the DirectSetup redist to deploy. Most audio middleware solutions use WASAPI directly on Windows Vista+, so these are reasonable options. You could use legacy DirectSound8, and the headers for that are at least in the Windows 8.x SDK that comes with VS 2012/VS 2013.
If you need Windows XP support, then require Windows XP Service Pack 3 as the minimum OS. This will include DirectX 9.0c and WIC components as part of the OS.
You'll need to use Direct3D 9 and DirectSound8
Avoid using D3DX9 at all so all HLSL shaders would have to be pre-built offline, and you can't use the Effects (FX9) system or D3DXMath.
If you are using VS 2012/VS 2013, you can target Windows XP using the *_xp Platform Toolset, but remember that that uses the Windows 7.1A SDK and not the Windows 8.x SDK so it has some implications for DirectX development.
Direct3D 9 debugging on Windows 8.0 or later is also a huge pain as there's no developer runtime available for it.
All of this assumes you are using C++. Using .NET is not realistic as the deployment story for .NET is rather complicated. You could in theory use .NET 2.0 if you require Windows Vista+ or later, but it may require enabling a Windows feature on some versions of the OS, and you can't count on any version of .NET to be present on Windows XP. .NET 4.0 is on by default for Windows 8.0+, but support for .NET 3.5 and earlier is off by default. However, all use of DirectX from C# requires additional assemblies which themselves likely have dependencies on the legacy DirectSetup deployment.

JavaFX and OpenJDK

I'm trying to decide whether I could switch to JavaFX for the user interface of my Java application. Most of my users would be using the Oracle JRE, which has JavaFX integrated these days. However, some are using OpenJDK (on linux). This (old) question suggests that OpenJDK deals very badly with JavaFX. According to this question, the alternative OpenJFX will only be fully integrated into OpenJDK in version 9. So my question is twofold:
Is the JavaFX support in OpenJDK still so bad?
If so, are there any Linux distributions that already offer an OpenJFX package so users wouldn't have to build it themselves?
JavaFX is part of OpenJDK
The JavaFX project itself is open source and is part of the OpenJDK project.
However, the OpenJDK project includes many projects, including incubating projects and other projects, such as OpenJFX, whose source and implementation are not shipped as part of some JDK/JRE distributions (e.g. Oracle JDK 11+ implementations and many open-source JDK Linux package installations do not include JavaFX runtimes).
Modern JavaFX distributions are modules
JavaFX is not part of most JDK 11+ downloads, it is usually downloaded by developers as modules or a separate SDK.
Specifically for JavaFX 11+, as detailed on the https://openjfx.io site:
JavaFX runtime is available as a platform-specific SDK, or as a number of jmods, or as a set of artifacts in Maven Central.
This means that JavaFX can be used from any modern JDK running on a supported platform, by including the appropriate JavaFX modules (available from openjfx or Maven Central) on the runtime module path.
All JavaFX modules available from openjfx are open source implementations that contain no closed source code.
For distribution of JavaFX-based applications to end-users, it is advised to package a run-time image distribution based on the JDK and JavaFX modules + required dependent library code and application code. A full discussion of this packaging is out of scope for this answer, but one can create a distribution based purely on open-source JDK+JavaFX+library+application code if desired. See the openjfx.io documentation on run-time images for some more (though not comprehensive) information on this.
Update Sep 2021
Also, see the related question:
JavaFx in oracle JDK 8 is same as openjfx 8 versions or not? what is the relationship between javafx in oracle jdk 8 and openjfx8?
Which covers information regarding Java 8 and also some later versions.
Update Dec 2019
For current information on how to use Open Source JavaFX, visit https://openjfx.io. This includes instructions on using JavaFX as a modular library accessed from an existing JDK (such as an Open JDK installation).
The open source code repository for JavaFX is at https://github.com/openjdk/jfx.
At the source location linked, you can find license files for open JavaFX (currently this license matches the license for OpenJDK: GPL+classpath exception).
The wiki for the project is located at: https://wiki.openjdk.java.net/display/OpenJFX/Main
If you want a quick start to using open JavaFX, the Bellsoft's Liberica JDK distributions provide pre-built OpenJDK binaries that include OpenJFX for a variety of platforms.
For distribution as self-contained applications, Java 14 is scheduled to implement JEP 343: Packaging Tool, which "Supports native packaging formats to give end users a natural installation experience. These formats include msi and exe on Windows, pkg and dmg on macOS, and deb and rpm on Linux.", for deployment of OpenJFX based applications with native installers and no additional platform dependencies (such as a pre-installed JDK).
Older information that may become outdated over time
Building JavaFX from the OpenJDK repository
You can build an open version of OpenJDK (including JavaFX) completely from source which has no dependencies on the Oracle JDK or closed source code.
Update: Using a JavaFX distribution pre-built from OpenJDK sources
As noted in comments to this question and in another answer, the Debian Linux distributions offer a JavaFX binary distibution based upon OpenJDK:
https://packages.qa.debian.org/o/openjfx.html
Install via:
sudo apt-get install openjfx
(currently this only works for Java 8 as far as I know).
Differences between Open JDK and Oracle JDK with respect to JavaFX
The following information was provided for Java 8. As of Java 9, VP6 encoding is deprecated for JavaFX and the Oracle WebStart/Browser embedded application deployment technology is also deprecated. So future versions of JavaFX, even if they are distributed by Oracle, will likely not include any technology which is not open source.
Oracle JDK includes some software that is not usable from the OpenJDK. The components that relate to JavaFX:
The ON2 VP6 video codec, which is owned by Google and Google has not open sourced.
The Oracle WebStart/Browser Embedded application deployment technology.
This means that an open version of JavaFX cannot play VP6 FLV files. This is not a big loss as it is difficult to find VP6 encoders or media encoded in VP6.
Other more common video formats, such as H.264 will playback fine with an open version of JavaFX (as long as you have the appropriate codecs pre-installed on the target machine).
The lack of WebStart/Browser Embedded deployment technology is really something to do with OpenJDK itself rather than JavaFX specifically. This technology can be used to deploy non-JavaFX applications.
It would be great if the Open Source community developed a deployment technology for Java (and other software) which completely replaced WebStart and Browser Embedded deployment methods, allowing a nice light-weight, low impact user experience for application distribution. I believe there have been some projects started to serve such a goal, but they have not yet reached a high maturity and adoption level.
Personally, I feel that WebStart/Browser Embedded deployments are legacy technology and there are currently better ways to deploy many JavaFX applications (such as self-contained applications).
Update Dec, 2019:
An open source version of WebStart for JDK 11+ has been developed and is available at https://openwebstart.com.
Who needs to create Linux OpenJDK Distributions which include JavaFX
It is up to the people which create packages for Linux distributions based upon OpenJDK (e.g. Redhat, Ubuntu etc) to create RPMs for the JDK and JRE that include JavaFX. Those software distributors, then need to place the generated packages in their standard distribution code repositories (e.g. fedora/red hat network yum repositories). Currently this is not being done, but I would be quite surprised if Java 8 Linux packages did not include JavaFX when Java 8 is released in March 2014.
Update, Dec 2019:
Now that JavaFX has been separated from most binary JDK and JRE distributions (including Oracle's distribution) and is, instead, available as either a stand-alone SDK, set of jmods or as a library dependencies available from the central Maven repository (as outlined as https://openjfx.io), there is less of a need for standard Linux OpenJDK distributions to include JavaFX.
If you want a pre-built JDK which includes JavaFX, consider the Liberica JDK distributions, which are provided for a variety of platforms.
Advice on Deployment for Substantial Applications
I advise using Java's self-contained application deployment mode.
A description of this deployment mode is:
Application is installed on the local drive and runs as a standalone
program using a private copy of Java and JavaFX runtimes. The
application can be launched in the same way as other native
applications for that operating system, for example using a desktop
shortcut or menu entry.
You can build a self-contained application either from the Oracle JDK distribution or from an OpenJDK build which includes JavaFX. It currently easier to do so with an Oracle JDK.
As a version of Java is bundled with your application, you don't have to care about what version of Java may have been pre-installed on the machine, what capabilities it has and whether or not it is compatible with your program. Instead, you can test your application against an exact Java runtime version, and distribute that with your application. The user experience for deploying your application will be the same as installing a native application on their machine (e.g. a windows .exe or .msi installed, an OS X .dmg, a linux .rpm or .deb).
Note: The self-contained application feature was only available for Java 8 and 9, and not for Java 10-13. Java 14, via JEP 343: Packaging Tool, is scheduled to again provide support for this feature from OpenJDK distributions.
Update, April 2018: Information on Oracle's current policy towards future developments
The Future of JavaFX and Other Java Client Roadmap Updates by Donald Smith, Sr. Director of Product Management, Oracle.
Java Client Roadmap Update - March 2018 an Oracle White Paper.
For me this worked.
$ sudo apt-get install openjfx
As a quick solution you can copy the JavaFX runtime JAR file and those referenced from Oracle JRE(JDK) or any self-contained application that uses JavaFX(e.g. JavaFX Scene Builder 2.0):
cp <JRE_WITH_JAVAFX_HOME>/lib/ext/jfxrt.jar <JRE_HOME>/lib/ext/
cp <JRE_WITH_JAVAFX_HOME>/lib/javafx.properties <JRE_HOME>/lib/
cp <JRE_WITH_JAVAFX_HOME>/lib/amd64/libprism_* <JRE_HOME>/lib/amd64/
cp <JRE_WITH_JAVAFX_HOME>/lib/amd64/libglass.so <JRE_HOME>/lib/amd64/
cp <JRE_WITH_JAVAFX_HOME>/lib/amd64/libjavafx_* <JRE_HOME>/lib/amd64/
just make sure you have the gtk 2.18 or higher
Also answering this question:
Where can I get pre-built JavaFX libraries for OpenJDK (Windows)
On Linux its not really a problem, but on Windows its not that easy, especially if you want to distribute the JRE.
You can actually use OpenJFX with OpenJDK 8 on windows, you just have to assemble it yourself:
Download the OpenJDK from here: https://github.com/AdoptOpenJDK/openjdk8-releases/releases/tag/jdk8u172-b11
Download OpenJFX from here: https://github.com/SkyLandTW/OpenJFX-binary-windows/releases/tag/v8u172-b11
copy all the files from the OpenFX zip on top of the JDK, voila, you have an OpenJDK with JavaFX.
Update:
Fortunately from Azul there is now a OpenJDK+OpenJFX build which can be downloaded at their community page: https://www.azul.com/downloads/zulu-community/?&version=java-8-lts&os=windows&package=jdk-fx
Try obuildfactory.
There is need to modify these scripts (contains error and don't exactly do the "thing" required), i will upload mine scripts forked from obuildfactory in next few days. and so i will also update my answer accordingly.
Until then enjoy, sir :)
I needed to run a .jar in Windows which required Java FX. I also didn't need the JDK part.
Note: I didn't bother changing the PATH/JAVA_HOME variables because it wasn't needed in my case, for a more complete walkthrough see: How to install OpenJDK 11 on Windows?
Download OpenJDK and Java FX (jmods) (version 17.0.2 for this example)
https://jdk.java.net/17/
https://gluonhq.com/products/javafx/
Unzip the downloaded files. Copy/move the .jmod files from the Java FX directory to the OpenJDK dir (jmods subdirectory).
Create a JRE with jlink, use this web app to get the exact command line options:
https://justinmahar.github.io/easyjre/
PowerShell snippet:
$Version = '17.0.2'
$DownDir = 'path\to\dir\with\.zip'
$JdkDir = "jdk-${Version}"
$JavaFxDir = "javafx-jmods-${Version}"
$NewDir = "jre-${Version}+javafx"
$ProgramFilesDir = "$env:ProgramFiles\OpenJDK\${NewDir}"
Set-Location -Path $DownDir
# Unzip archives
Expand-Archive -Path "openjfx-${Version}_windows-x64_bin-jmods.zip" -Destination .
Expand-Archive -Path "openjdk-${Version}_windows-x64_bin.zip" -Destination .
# Create a custom runtime image using jlink, excluding all modules that start with 'jdk.'
Copy-Item -Path "${JavaFxDir}\*.jmod" -Destination "${JdkDir}\jmods"
$Mods = Get-Item -Path "$JdkDir\jmods\*.jmod" | ? { !($_.Name -like 'jdk.*') }
$Mods = $Mods.Name -replace '.jmod$' -join ','
& "${JdkDir}\bin\jlink.exe" --output $NewDir --compress=2 --no-header-files --no-man-pages --module-path "${JdkDir}\jmods" --add-modules $Mods
# (Optional) Delete unzipped directories
Remove-Item -Path $JdkDir,$JavaFxDir -Recurse
# Test if the .jar works
$jar = Get-Item "\path\to\.jar"
& "${NewDir}\bin\javaw.exe" -jar $jar
# (Optional) Copy the new directory to Program Files (requires admin privileges), zip it to distribute to other computers and delete it
Copy-Item -Path $NewDir -Destination $ProgramFilesDir -Recurse
Compress-Archive -Path $NewDir -DestinationPath "openjdk-${Version}_jre+javafx_windows-x64_bin.zip"
Remove-Item -Path $NewDir -Recurse
# (Optional) Create shortcut in Desktop
$Lnk = "$env:USERPROFILE\Desktop\Shortcut.lnk"
$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($Lnk)
$Shortcut.TargetPath = "${ProgramFilesDir}\bin\javaw.exe"
$Shortcut.WorkingDirectory = $jar.DirectoryName
$Shortcut.Arguments = '-jar "' + $jar.FullName + '"'
$Shortcut.Save()
According to Oracle integration of OpenJDK & javaFX will be on Q1-2014 ( see roadmap : http://www.oracle.com/technetwork/java/javafx/overview/roadmap-1446331.html ). So, for the 1st question the answer is that you have to wait until then. For the 2nd question there is no other way. So, for now go with java swing or start javaFX and wait
I used Amazon Coretto JDK. This had all FX Components I needed.

How portable is JavaFX 2?

I am thinking of kicking off a JavaFX project on my 64-bit Windows 7 machine. What I am doing is designing a full-screen console application. It's not interactive aside from a barcode scanner.
I'm designing this for what I think would be an Ubuntu laptop or some other Linux variation, although a different Windows OS is a possibility too (as well as 32 bit). From what I understand Java FX version 2.x has made great advancements in portability from its predecessor, but I wanted to ask the community here what their experience was in deploying JavaFX apps.
Have you had success using them on a variety of different architectures? What are some problems you have encountered?
Checkout EstiMate for an example of an all-in-one jar which is runnable via double click.
https://bitbucket.org/atill/estimate/downloads
It requires Java7u10 installed. I plan to make a proper installer for it later on, using the javafx maven plugin. https://github.com/zonski/javafx-maven-plugin. I haven't tested it on Linux or Mac but it does work across winXP 32bit and 64bit windows7.
As long as your barcode scanner works the same on ubuntu as on win and you are not using any external libraries, you won't notice the difference between those systems from your app.
I found installing oracle JRE on ubuntu the most difficult task. (with JRE_HOME, etc.) Even on Archlinux was easier than ubuntu.
Nevertheless, once the JRE is set, your app will run even on Raspberry Pi (which is ARM not x86)
Remember about file system differences between systems.

Javafx 2.2 and Snow Leopard

I need to deploy a JavaFX2.2 application on Mac machines. OS X 10.7 or later are fine with Java 7u7. What about OS X 10.6? Do we have any workaround? I think 10.6 can update upto Java 6u35 and somewhere I read 2.1 & 2.2 can run with 6u26 or later (However there are no support though which is ok).
Can someone please help me to accomplish this? Can we just download standalone JFX2.2 runtime from somewhere and put it on OSX10.6? Or any other alternative option? Is there a way we can copy/package 2.2 runtime along with the app itself?
Please help.
Is there a way we can copy/package 2.2 runtime along with the app itself?
Yes, see the documentation on self-contained application packaging which is supported on OS X 10.7+ and includes JavaFX 2.2+ and jre7u6+.
What about OS X 10.6?
Quote from an oracle forum thread by the JavaFX lead regarding Snow Leopard support and JavaFX 2.2:
FWIW, there are in fact some APIs we use from Lion that aren't on Snow Leopard. Also, Apple only supports the current release of the OS - 1 (so now it would be Lion and Mountain Lion), and for deployment we needed special hooks. The thought was that it didn't make sense to support versions of the Mac OS that Apple themselves didn't support any longer.
Some of the early developer builds of JavaFX (2.0/2.1) did run on Snow Leopard, but they were only early development builds and not production ready, plus, I don't think the license on those builds allow you to use them in production code. I don't think these early 2.0/2.1 development builds are distributed by Oracle anymore.
When JavaFX is fully open sourced, you might be able to undertake an effort to backport it to Snow Leopard, but by then it probably wouldn't be worth it.
As a hack, you could try adding the JavaFX runtime bundled in jre7u7+ to an Apple Java6u35 and see if you can run an app - but this would be a totally unsupported configuration likely to break and may also have distribution licensing issues.
Reasons why mac does not work with javafx.. currently
From: https://blogs.oracle.com/henrik/entry/oracle_jdk_and_javafx_sdk
Quote:
Note that support on Mac is for development only; e.g. we don't expect your Mac to be running a business critical server-side application...
Context: JavaFx is still in development on mac since java7, full on support was expected at java 8. Java 8 will be real eased september
From: http://www.oracle.com/technetwork/java/javafx/downloads/supportedconfigurations-1506746.html
Quote:
MacOs is only supported in 10.7.3 or greater (Mac OS X Lion, the second newest operating system)
Context: Stating JavaFx supported configurations. There are many browsers where JavaFx will not work!
From: http://docs.oracle.com/javafx/
Quote:
JavaFX applications run on a desktop. On Windows, they also run in a browser, and over the web.
Context: This with following quote implies only developmental progress on macOS
From: http://ed4becky.net/homepage/javafx-from-the-trenches-part-2-its-not-always-about-the-sex/?rcommentid=26916&rerror=incorrect-captcha-sol&rchash=35499a8f4e0544f950435495d20b0cf1#commentform
Quote:
Turns out there is a bug in the ChoiceBox – JIRA RT-26837 I talk about on the JavaFX2 Forum. It got the attention of Jonathan Giles at Oracle, and he escalated the fix, but it won’t be out until Java8 is released.
Context: There are still a lot of bugs that will keep you from success on mac!

Installing MonoDevelop on Suse Enterprise 10.0

I tried to install MonoDevelop on Suse 11.0 Enterprise, using the 1-click install on the MonoDevelop download page, but quickly wound up in a tangle of missing dependencies. I then tried using the Suse software repositories to get MonoDevelop, and waded through several of the dependencies for awhile trying to get the necessary packages to fulfill the dependencies, but some of the packages in the Suse repositories actually appear to be missing the needed RPM files. Are these repositories no longer being actively maintained?
I am aware that there is a CD on the Mono site (called the Mono LiveCD) that appears to contain a complete installation of the development environment, as well as a DVD for OpenSuse 11.2 (on the OpenSuse site) that might actually have all of the Mono software already installed. But the target environment for the utility I am writing is Suse 11.0 Enterprise Server. Does that matter?
What is the shortest distance between two points here?
that might actually have all of the Mono software already installed.
It has all of the Mono software installed ( of course it depends on what do you mean 'all') Last time when i tried it, the installation included Mono itself, monodevelop, MoMa and some software, written in Mono ( gome-do, for example ). I did not perform any additional steps for migrating my solution from a windows machine. the one thing worth to mention, monodevelop crashed several times, but i think it was memory-related ( an image had access only to 512 mb of RAM ).
But the target environment for the
utility I am writing is Suse 11.0
Enterprise Server. Does that matter?
In theory, it does not. You will have to check Mono versions of course, but i don't think you will face any problems during migration process. As far as i know, Suse 11.0 comes with Mono 2.0 pre-installed. With a latest life-cd you are going to develop using mono 2.6. There were some major changes ( partial LINQ to SQL suport ) you will have to compare changelog's of course.
If you're trying to install Mono on Suse Linux Enterprise Server, you need to download the Mono Extension Pack (available here). In SLES 11 it was separated out into a separate product in order to decouple the support life cycle from that of the general distribution. This allows them to release more often.
The add-on is available for x86, x86_64, and IBM System Z.

Resources