Support > Repository > Business logic > Points to note when using Java 6/7
ja | en

In Java 6/7 there are some different scripting rules.

Java ships with the following server side JavaScript engine.

Java versionEnclosed JavaScript engine
Java 8Nashorn
Java 6/7Rhino

All the code exemplified in this document is based on how to write in Java 8 (Nashorn).This page explains the changes when operating in Java 6/7 (Rhino).

Java 8 (Nashorn)

Use the variable stdout.

stdout.println("Hello from Nashorn.");

Java 6/7 (Rhino)

In Rhino you can use println directly.

println("Hello from Rhino.");

Java arrays are implemented using java.lang.reflect.Array.newInstance.

The following example creates a character array in a script.

var obj = java.lang.reflect.Array.newInstance(java.lang.String, 1);
obj[0] = "テストです。";
p.errors.addJfcerror(errorManager.getJfcerror("error.original", obj, p.locale));

When using Java classes in scripts, Java.type can be used when using Java 8 environment.

Var Foo = Java.type ("jp.jasminesoft.wagby.Foo"); var foo = new Foo;

When using Java 6/7, use importClass.At this time, it is necessary to declare function process at the same time.

ImportClass (; importClass (; importClass (; importClass ( ImportClass (; / * added * / function process () {... Write your own code here.


In other words, in the Java 8 environment, you can skip the function definition called function process (), but in Java 6/7 you need to define the function at the time you use the importClass declaration.

In that case, it is a good idea to add the classes (ExcelFunction and Jfcerror) frequently used in the code at the same time to the declaration as shown above.