Platform-specific notes for the JVM

Unix-based platforms

The JAVA_HOME environment variable must be set to use the Java interface on Unix-based platforms platforms.

If needed, the LD_LIBRARY_PATH environment variable can contain the path to the JVM library. This is however not required if JAVA_HOME is properly set.

Microsoft™ Windows®

The JAVA_HOME environment variable must be set to use the Java interface on Microsoft Windows platforms.

If needed, the PATH environment variable can contain the path to the JVM library. This is however not required if JAVA_HOME is properly set.

Important: If PATH is defined to find the javac compiler or JVM library, make sure that it does not contain double quotes around the path to the JVM.DLL dynamic library, otherwise the DLL loader will fail to load the JVM.

See also Microsoft Windows configuration notes.

Mac® OS X®

The JAVA_HOME environment variable must be set to use the Java interface on Mac® OS X.

To find the JAVA_HOME path on Mac OS X, use the /usr/libexec/java_home tool:
export JAVA_HOME=`/usr/libexec/java_home`
Note: On Mac OS X, the usage of DYLD_LIBRARY_PATH is strongly discouraged, especially since OS X 10.11 this environment variable is no longer exported in sub processes.

The Genero runtime system uses the Java Native Interface (JNI) to interact with the JVM and execute Java code.

By default on Mac OS X, the JNI feature may not be activated.

To ensure that Java is installed, execute the following command:
$ /usr/libexec/java_home
The output should look like:
Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
To ensure that JNI is enabled, use the -t JNI option:
$ /usr/libexec/java_home -t JNI
The output should look like:
Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home

If the output is empty or reports an older version, JNI is not enabled for the default Java installation.

To enable JNI, edit the Info.plist file:
$ sudo vi `/usr/libexec/java_home`/../Info.plist
And add "<string>JNI</string>" in the <array> of the JVMCapabilities key:
      <dict>
              <key>JVMCapabilities</key>
              <array>
                      <string>CommandLine</string>
                      <string>JNI</string>
              </array>

See also Mac OS X configuration notes.

Android™

The Java Interface can be used in Genero apps built for the Android / GMA platform.

On Android devices, custom Java classes need to be part of the .apk package and can be used without any further configuration.

Note: On Android devices, some system functions can only be accessed in the context of a JVM. Use the Java Interface with the com.fourjs.gma.vm.FglRun class to access such system specifics.

For more details, see Executing Java code with GMA.

iOS

Important:

The Java interface cannot be used in apps running on iOS devices: There is no standard free JVM available.

IBM® AIX®

Consider the following notes when using the Java Interface with the IBM Java VM on AIX:

If you get java.lang.UnsatisfiedLinkError exceptions, set the path to native shared libraries in the LIBPATH environment variable:

$ LIBPATH=$JAVA_HOME/jre/bin:$JAVA_HOME/jre/bin/j9vm:$JAVA_HOME/jre/lib/ppc64:$LIBPATH
$ export LIBPATH

This is required when using Java code that needs to access native code supplied as part of the JRE. For example, without setting LIBPATH to the appropriate path, the JVM cannot find the shared library libnet.so.

Using the -Djava.library.path=path-to-native-library java VM option does not seem to help.

See also IBM AIX configuration notes.

HP-UX®

Consider the following notes when using the HotSpot JVM on HP/UX:

If you get an error when fglcomp or fglrun try to load the libjvm library, define the LD_PRELOAD environment variable as follows:

$ LD_PRELOAD=libjvm.sl
$ export LD_PRELOAD

Using LD_PREPLOAD can cause other applications fail. LD_PRELOAD should only be set for the runtime system. If you need to run other applications in the same environment as your application programs, you can set the LD_PRELOAD_ONCE or JAVA_PRELOAD_ONCE variable in the shell scripts found in FGLDIR/bin.

See also HP-UX configuration notes.