Java Properties: Part 2

Load a properties file from current directory.

Properties properties = new Properties();
properties.load(new FileReader(new File(".").getCanonicalPath() + File.separator + ""));

Write a start script

#! /bin/bash
scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $scriptdir
java -jar MyExecutable.jar
cd -

Now you can start your configurable java program from any location, e.g. by linking the startscript to /usr/bin/ .

Leave a Reply