Skip to content

JDK regression: JavaScript not supported as scripting language #308

@plaa

Description

@plaa

The Oracle JDK and OpenJDK comes built-in with support for JavaScript scripting. When I created the scripting support in the simulation extensions, JavaScript was intended to be supported on all systems by default. Now when I start OpenRocket on Linux Mint 18 running OpenJDK 1.8.0_111 no scripting languages are supported. I believe this is caused by changing from OpenJDK 7 to 8 (at which point the Rhino engine was changed to the Nashorn engine as well).

For debugging I added the following code to both OpenRocket.java and SwingStartup.java:

	ScriptEngineManager mgr = new ScriptEngineManager();
	List<ScriptEngineFactory> factories = mgr.getEngineFactories();
	
	for (ScriptEngineFactory factory : factories) {
		System.out.println("ScriptEngineFactory Info");
		String engName = factory.getEngineName();
		String engVersion = factory.getEngineVersion();
		String langName = factory.getLanguageName();
		String langVersion = factory.getLanguageVersion();
		System.out.printf("\tScript Engine: %s (%s)%n", engName, engVersion);
		List<String> engNames = factory.getNames();
		for (String name : engNames) {
			System.out.printf("\tEngine Alias: %s%n", name);
		}
		System.out.printf("\tLanguage: %s (%s)%n", langName, langVersion);
	}

It's evident that initially when starting OpenRocket JavaScript is supported (in OpenRocket.java) but after the startup classpath changes (in SwingStartup.java) the support is no longer present. I'm unsure why the classpath updates no longer keep the default nashorn.jar on the classpath or how to fix the issue.

As a workaround, copying /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/nashorn.jar to ~/.openrocket/Plugins/ fixes the issue, as this forces nashorn.jar to be on the updated classpath.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions