Thursday, May 5, 2011

How do you configure GroovyConsole so I don't have to import libraries at startup?

I have a groovy script that uses a third party library. Each time I open the application and attempt to run my script I have to import the proper library.

I would like to be able to open GroovyConsole and run my application without having to import the library.

From stackoverflow
  • At least on Linux groovy GroovyConsole is a Script has the Following command:

    startGroovy groovy.ui.Console "$@"
    

    startGroovy itself is a script which starts Java. Within the startGroovy script you should be able to modify your classpath and add the missing librarys.

    From startGroovy:

    startGroovy ( ) {
        CLASS=$1
        shift
        # Start the Profiler or the JVM
        if $useprofiler ; then
            runProfiler
        else
            exec "$JAVACMD" $JAVA_OPTS \
                -classpath "$STARTER_CLASSPATH" \
                -Dscript.name="$SCRIPT_PATH" \
                -Dprogram.name="$PROGNAME" \
                -Dgroovy.starter.conf="$GROOVY_CONF" \
                -Dgroovy.home="$GROOVY_HOME" \
                -Dtools.jar="$TOOLS_JAR" \
                $STARTER_MAIN_CLASS \
                --main $CLASS \
                --conf "$GROOVY_CONF" \
                --classpath "$CP" \
                "$@"
        fi
    

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.