• Skip to content

Justin Monsees

A life-long learner's development blog

  • About Me
  • Projects
  • Contact

Mar 16 2019

Deploying Java Application with Maven – Part II

OK here’s part 2 of my blog posts about deploying an application using Maven. The last post showed how to deploy an application for the MacOS. This post will show you how to leverage the Maven use of profiles. In this case the <Profiles> XML tag is used to determine which operating system the application is being built with to determine which bundle settings to use for the packaging phase. Using these settings, if a developer is using a PC to build this program, it will package the program into an MSI installer, on Mac it will package a dmg, and Linux it will package a deb. OK so here’s the code:

  1. First add the profiles section to the POM.xml. This detects the type of OS and then stores the installation bundle type in the variable called “installer.bundler.” Here’s the section of code for the profiles section:
  2. In the plugins section, you find a block for the “javafx-mavin-plugin.” This is the plugin that builds the installation bundle. In the configuration section, add this code:
  3. Now save the project, right click on the main project folder and select Run Maven->Goals
  4. Now enter the goal as “package” without the quotes and select OK
  5. Locate the project folder in your finder. On my Mac, it’s located in my home->Netbeans Projects->ProjectFolder->target->jfx->native. That folder should have the .dmg for your application that can now be run on your computer. On my PC, my project is located in My Documents->NetBeansProjects->MavenSample->target->jfx->native. That folder should now have the MSI installer file.

In short, Maven is incredibly powerful in generating installation packages for your Java applications. By using profiles, you can create the installation file for the operation system on which the application is packaged. This creates a more portable project because now, even cross platform, the POM.xml file doesn’t need to be changed.

Written by admin · Categorized: Uncategorized

Nov 29 2018

Deploying a JavaFX Program with Maven

Maybe you’ve run into a similar situation as me. I’ve taken Java classes at colleges and I’ve also been learning Java on my own free time making applications.  When I first learned Java, I started to learn to make GUI applications using Swing. Then I found JavaFX. WOW! Gamechanger! So I spent the time to learn JavaFX and built this sweet program that is actually pretty handy for work. Only one thing, nobody ever taught me how to deploy an application in a format that everyday people could use. In class, I’ve only ever submitted my code files so the teacher could see the code.

But what about when you have a useful application that you actually want people to install and use on their computer?!

This post is part 1 of my discovery on how to create a native package for MacOS for a JavaFX application. I’ve yet to test this on a PC but it should create an exe with this same methodology when compiled on a PC. I’ll post more on this in a separate post.

OK here goes! First off let me set the parameters of how I’m creating this simple Java program:

  • I’m using Netbeans, version 8.2
  • I’ve created a Maven project (If you haven’t used Maven and are new to Java, I would definitely look into this)

OK so here’s the process:

  1. In Netbeans, go to File->New Project
  2. Under the “Maven” category, select the “JavaFX Application” project
    1. This creates the Maven project folder structure and a default POM.xml
    2. The POM.xml is the xml file that is used to customize and tell Maven how to build your project. This file can tell Maven, to include other Java libraries, make a Jar or War file, or use Maven plugins (which is what we’ll need to create the native installer)
  3. Open the POM.xml file under the “Project Files” folder
  4. Under the “plugins” xml tag, create add this code:
  1. Now save the project, right click on the main project folder and select Run Maven->Goals
  2. Now enter the goal as “package” without the quotes and select OK
  3. This is where the magic happens, and Maven is going to package that JavaFX application into a MacOS application.
  4. Locate the project folder in your finder. For me it’s located in my home->Netbeans Projects->ProjectFolder->target->jfx->native. That folder should have the .app, .dmg, and .pkg files for your application that can now be run on your computer.

Written by admin · Categorized: Java · Tagged: deployment, java, javafx, javafx packager, maven

Aug 05 2018

Automating Indesign with Javascript

Adobe InDesign is an incredibly powerful document layout tool. One of the greatest features that make it even more powerful though it the ability to write scripts to automate document creation. In this post, the aim is just to give an overview of:

  • What scripting allows you to do
  • Scripting choices
  • How to get started with scripting
  • Examples of how scripting can be used

What does scripting allow you to do?

Scripting allows you to automate functions that InDesign can perform using code. Think of it this way, basically anything that you can interact with in InDesign by using your mouse and keyboard, you can control with code. So simple things like opening documents, creating new documents, exporting documents as PDFs, closing documents etc can be done with code. This allows you to do really repetitive work and also some dynamic work where some logic is involved in a short amount of time.

Scripting Choices

InDesign actually gives you a choice of scripting languages that you can use. The choices are Applescript or Javascript. Going forward, I’ll only be talking about Javascript since that’s been my main focus. If you’re familiar with Applescript already and only plan on ever having your scripts be used on Apple computers, then have at it. Otherwise, Javascript is the way to go. In my opinion, Javascript is a really good language to learn. The syntax is very similar to Java and the Javascript that you might use if you were designing websites. My main reason for using Javascript, however, is the fact that is is platform independent. By that, I meant that you can use it on Apple computers or regular PCs. You might have to tweak the code a little if you’re using operating system specific stuff like accessing hard drives though. In the end, Javascript means that you can use it on any computer and more people can use your script.

How to get started with scripting

If you’ve never used scripting before, finding the functionality in InDesign is the first step. In fact, InDesign actually comes with a decent amount of sample scripts out of the box. To access this go to the menu bar at the top and click on Window->Utilities->Scripts. This opens up the scripts panel which looks a bit like a file directory. To access the sample scripts, double click on Application -> Samples. There you’ll see folders for Javascript and Applescript. Clicking on either one brings up a whole list of individual scripts. Scripts can be run by simply double clicking on them. If you want to view or edit the code, you can open the files with any text editor. But for development, you should get Extendscript. If you have InDesign, it’s a free IDE offered by Adobe to develop and test scripts. It also has an excellent reference called “Object Viewer Model.” I use that quite often when trying to implement new functionality.

Real examples of how scripting can be used

  • Creating variable data documents such as mailing labels by importing data from Microsoft Excel files
  • Customizing a template document such as a Welcome Guide and exporting the PDF so users don’t actually have to manually edit an InDesign document
  • Creating business cards from an InDesign template using data from Excel
  • Exporting information from a document to a comma delimited file

What repetitive tasks are you doing with InDesign that could be automated? If you’re already using scripting, what type of projects have you completed?

 

Written by admin · Categorized: Javascript for InDesign · Tagged: automation, InDesign, Javascript, scripting

© 2025 Justin Monsees