In your Java application you may want to run another Java application.
In order to do this, you need to know where is the bin/java
executable.
It's in the JAVA_HOME
(environment variable), which is not always set.
Instead of looking for this place manually, just use this small one-class
library.
First, you add this to your pom.xml
:
<dependency>
<groupId>com.yegor256</groupId>
<artifactId>jhome</artifactId>
<version>0.0.5</version>
</dependency>
Then, you use it like this:
import com.yegor256.jhome;
Path p = new Jhome().path("bin/java");
The result is the location of bin/java
inside JAVA_HOME
.
Also, you can use java()
and javac()
methods in order to get the full path
to java
and javac
executables respectively:
import com.yegor256.jhome;
Path java = new Jhome().java();
Path javac = new Jhome().javac();
Fork repository, make changes, send us
a pull request.
We will review your changes and apply them to the master
branch shortly,
provided they don't violate our quality standards. To avoid frustration,
before sending us your pull request please run full Maven build:
$ mvn clean install -Pqulice
You will need Maven 3.3+ and Java 8+.