I’m writing a Java program that’s supposed to be the GUI frontend that utilizes a tertiary C program to generate some values for various labels.
But I don’t want have to hard code the path to the C program. I just want the Java Program to execute the C program on the assumption that it’ll be in the same directory that I had run the Java program from (otherwise have an error message prompt).
I’ve never used processbuilder before so I’ll appreciate extensive examples 🙂
One way to get the path of the jar containing the current Java code is the following (where “THISCLASS” is the name of a class):
Given the path to the jar file, you can use the java.io.File API to travel a relative path to the executable.