Is it possible to get the Finde-Selection directly in Java without any help of Applescipt? Basically its possible by executing an osascript in Java which calls another applescript that passes the Finder-selection as a string. thx.
import java.io.*;
public class FinderSelection {
public static void main(String [] args) throws IOException {
String[] cmd = { "osascript", "-e", "run script \"FinderSelection.scpt\" as POSIX file" };
InputStream is = Runtime.getRuntime().exec(cmd).getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader buff = new BufferedReader (isr);
String line;
while((line = buff.readLine()) != null)
System.out.println(line);
}
}
FinderSelection.scpt
tell application "Finder"
set theSelection to selection
set item1 to POSIX path of (item 1 of the theSelection as alias) as string
end tell
** EDIT **
I made a library. You can get it here on github.