This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 242171 - AppleScript Engine not supported?
Summary: AppleScript Engine not supported?
Status: RESOLVED WONTFIX
Alias: None
Product: platform
Classification: Unclassified
Component: JDK Problems (show other bugs)
Version: 7.4
Hardware: Macintosh (x86) Mac OS X
: P2 normal (vote)
Assignee: Tomas Zezula
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-20 21:09 UTC by thisguy
Modified: 2014-02-21 07:53 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description thisguy 2014-02-20 21:09:18 UTC
This code, does not find the AppleScript engine.
- Isn't this engine part of the Java 7 now?


	String script = "osascript -e tell app \"Outlook\" to launch";
	String sayOutlook = "say -v vicky \"Starting Outlook\"";

	ScriptEngineManager mgr = new ScriptEngineManager();
	ScriptEngine engine = mgr.getEngineByName( "AppleScript" );
	if( engine == null )
	{
		System.err.println( "AppleScript engine not found." );
	}
	else
	{
		try
		{
			engine.eval( sayOutlook );
		}
		catch( ScriptException ex )
		{
			String msg = ex.toString();
			String x = "";
		}
		catch( Exception ex )
		{
			String msg = ex.toString();
			String x = "";

		}

	}
Comment 1 Vladimir Riha 2014-02-21 07:15:07 UTC
I don't have a Mac to try it but this doesn't look like related to JavaScript, reassigning to to Java/project (please reassign to proper component if I'm wrong, thank you).
Comment 2 Tomas Zezula 2014-02-21 07:53:57 UTC
Nothing to do with java project.
>This code, does not find the AppleScript engine.
>- Isn't this engine part of the Java 7 now?
In fact it's even more complicated.
The original AppleScript engine was done by Apple as an extension of Apple's JDK,
it was placed in the /System/Library/Java/Extensions/. However the folder was removed by an MacOS X (XCode) update. This was the bad part.
Now the "good part". The AppleScript engine is bundled as a part of Oracle JDK 7 (in rt.jar the apple.applescript) however it's renamed and not registered.
So you need to do following things to get your program running:

1) change
ScriptEngine engine = mgr.getEngineByName( "AppleScript" );
to
ScriptEngine engine = mgr.getEngineByName( "AppleScriptEngine" );

2) register the AppleScript engine factory. Even it's in rt.jar it's not registered, so you need to register it in your jar (application).
You need to create folder:
"META-INF/services" in your source root, in it create a file "javax.script.ScriptEngineFactory" and paste following line into it:
apple.applescript.AppleScriptEngineFactory
This causes that the AppleScriptEngineFactory will be found by ServiceLoader.

3) Clean and build your project and the application should run.