applescript and java

Hi,

I want to call an applescript from Java. This works fine for some
scripts. But the following script doesn’t work:

String script =
“tell application "System Events" \n”
+ “do shell script "/System/Library/CoreServices/Menu\
Extras/User.menu/Contents/Resources/CGSession -switchToUserID 1000 "
\n”
+ “delay 2 \n”
//+ “keystroke "” + pw + “"”
+ “keystroke "password" \n”
+ “delay 1 \n”
+ “keystroke return \n”
+ “end tell”;

…with the following error:

NSAppleScriptErrorBriefMessage = “Expected \U201c"\U201d but found
unknown token.”;
NSAppleScriptErrorMessage = “Expected \U201c"\U201d but found
unknown token.”;
NSAppleScriptErrorNumber = -2741;
NSAppleScriptErrorRange = <00000055 00000001 >;

Does anyone know why?

The script without Java works fine…

Thanks,

Peter