1

I installed Rachota -- a time tracking program written in Java -- from the Fedora repo, and yum installed the rachota.jar file to /usr/share/java, but it also created a script at /usr/bin/rachota. That script is used to launch Rachota, instead of calling java directly.

I'm trying to figure out if there's a way to pass command line arguments to the /usr/bin/rachota script and get them passed to java.

The script is part of the JPackage project and looks like this:

#!/bin/sh
#
# rachota script
# JPackage Project <http://www.jpackage.org/>

# Source functions library
_prefer_jre="true"
. /usr/share/java-utils/java-functions

# Source system prefs
if [ -f /etc/java/rachota.conf ] ; then
  . /etc/java/rachota.conf
fi

# Source user prefs
if [ -f $HOME/.rachotarc ] ; then
  . $HOME/.rachotarc
fi

# Configuration
MAIN_CLASS=org.cesilko.rachota.gui.MainWindow
BASE_FLAGS=""
BASE_OPTIONS=""
BASE_JARS="rachota"

# Set parameters
set_jvm
set_classpath $BASE_JARS
set_flags $BASE_FLAGS
set_options $BASE_OPTIONS

# Let's start
run "$@"

Obviously it's parsing /etc/java/rachota.conf and $HOME/rachotarc, but my shell scripting experience is pretty limited, and I can't figure out what to put in the $HOME/.rachotarc file to pass the arguments.

This is the java command I want to eventually run:

java -Duser.language=en -Duser.country=GB -jar /usr/share/java/rachota.jar

The jar parameter is passed automatically, but I want to pass the Duser.language and Duser.country parameters too.

1
  • This should also be tagged JPackage, but I don't have the points yet. Could somebody please do that?
    – Ian Dunn
    May 23, 2012 at 3:32

1 Answer 1

2

The important part is the /usr/share/java-utils/java-functions file. I just found it online and it seems to support additional flags. After looking at the file (the run and the set_flags functions are the important ones) it seems that it should be enough to provide ADDITIONAL_FLAGS to the command:

ADDITIONAL_FLAGS="-Duser.language=en -Duser.country=GB" /usr/bin/rachota

If you want to debug it you may want to set VERBOSE to print more details about the executed argument:

VERBOSE=1 /usr/bin/rachota

If you want to have these settings persistent you can also set the variables directly in $HOME/.rachotarc or /etc/java/rachota.conf

1
  • I used ADDITIONAL_FLAGS="-Duser.language=en -Duser.country=GB" (without the /usr/bin/rachota), but it worked. Thanks :)
    – Ian Dunn
    May 23, 2012 at 6:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .