This is a followup to Prepping for Java, with specifics about setting up a Java development environment on Windows.
First, you have to install the JDK. I already had a Java JRE on my Windows system, so I went through the Control Panel and uninstalled all existing versions of Java first, though I don’t know if that’s really necessary. You can get the JDK from Oracle at this link. You will need to hit the button to accept their software license agreement first, then choose the appropriate version for your Windows installation. If in doubt, use the one for 32-bit Windows.
When you install the JDK, it will ask where you want to install it, with a default location being in a folder somewhere under “c:\Program Files”. Since some java tools may balk at spaces in the path name, you should change that to a path without spaces. I put mine in c:\apps\java\jdk but you can use any path you like.
Next, you’ll want to install an IDE. I prefer IntelliJ. Just download and run the installer as usual. You can download the ‘Ultimate’ edition if you like, though you’ll need to pay for it after a trial period, or you can download the Community edition, which will work fine too, it just doesn’t have quite as many bells and whistles. You can just take the defaults on everything to start with. All the add-ons and plug-ins can be installed later if you need them.
For JavaFX GUI work, you may want a copy of Scene Builder, which you can download at GluonHQ. (It used to be part of the JDK, but Oracle spun it off as open source.) It is optional — you can define your GUI entirely in XML, but Scene Builder does make visualization much simpler. Just download and install in the usual way. Again, if in doubt of which one to choose, go for the “x86” version.
And last but certainly not least, you’ll need Maven. You can grab the Windows version at this link. Download the zip version, and unzip it to someplace convenient. I put mine as a sibling of the jdk, at c:\apps\java\apache-maven-3.3.3. You will then need to update your system environment variables to change two things: First, update your path and add the “bin” folder of the maven installation to your path. Then you will need to add an environment variable called “JAVA_HOME” and set the value to the place you installed the JDK (in my case, c:\apps\java\jdk). You do not want the JAVA_HOME pointing to the binary folder, just to the main installation folder.
Now you should be able to open a new command prompt and try these two commands:
The first should tell you that Java is installed and what version it is. The second should verify that Maven is working and tell you what version it is. If the “java” command fails, make sure the jdk bin folder is in your path. (The JDK also installs a JRE, but you should prefer the jdk version of java for this purpose.) If the “mvn” command fails, check that you have your JAVA_HOME set correctly and that the maven binaries are in your path.
For building native installers for your java apps, you no longer need Launch4J. It does put a pretty GUI on a bewildering number of options, but you can more easily accomplish the same thing with the native installer tools built into the JDK directly. There is a maven plugin which adds a maven build action to make native installers for JavaFX applications with a simple command line: mvn clean jfx:native. That will make your JavaFX app seem like a native app, with its own bundled JRE and everything. The user need not worry about installing Java or anything, just run your installer, then run your app. Easy. Note that for multiple platforms, you will need to build the installer on each platform you intend to target.