Cristian
Cristian

Reputation: 41

Run Java file Service Mac

So far i've created a service using automator to compile a Java file. This means that i can compile a java file through its contextual menu.

Unfortunately I cannot do the same with running the Java file. Through automator I can get it to run the java file perfectly, showing the results in the automator window, however it will not open the Terminal window to view the java file. I did this using this code:

java -classpath `dirname "$1"` `basename "$1" | sed "s/.class//g"`

Applescript on the other hand can run Terminal commands into a Terminal window for all to see using code such as:

on run {input, parameters}
    tell application "Terminal"
        activate
        do script with command "java -classpath" & input & input
    end tell
end run

The correct way to run a java file is:

java -classpath /path/to/ file

Can anybody please help? Thanks in advance.

Upvotes: 0

Views: 990

Answers (1)

trashgod
trashgod

Reputation: 205865

Utilities > Run Shell Script with Passing input: as arguments seems to work in this context.

Addendum: If you want to open Terminal, something like this may work.

open -a Terminal ~/your/script.sh

Upvotes: 1

Related Questions