Archive · 4 August 2016
Installing SQLcl on OEL/RHEL
Written 10 years ago. Oracle APEX has moved on a lot since; check the current Oracle APEX posts too.

In my previous post I talked about how SQLcl came in handy to work with JavaScript against the database.
The installation of SQLcl is easy… you just download the zip, unpack and run the executable.
But to be fair, before I got SQLcl running (especially the script part) I encountered a number of issues, so hopefully this post helps you be able to run SQLcl with all features in minutes as it’s meant to be :)
Those were the error messages I received when running sql (script):
javax.script.ScriptException: sun.org.mozilla.javascript.EvaluatorException: Java class “java.util.ArrayList” has no public instance field or method named “0”.
javax.script.ScriptException: sun.org.mozilla.javascript.EcmaError: ReferenceError: “Java” is not defined. (#1) in at line number 1
The solution for me was to upgrade my Java version to Java 8.
Here’re the steps on my OEL/RHEL system to upgrade Java:
$ cd /opt
$ wget –no-cookies –no-check-certificate –header “Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie” “http://download.oracle.com/otn-pub/java/jdk/8u102-b14/jdk-8u102-linux-x64.tar.gz”
$ tar xzf jdk-8u102-linux-x64.tar.gz
$ cd jdk1.8.0_102/
$ alternatives –install /usr/bin/java java /opt/jdk1.8.0_102/bin/java 2
$ alternatives –config java
There are 5 programs which provide ‘java’.
Selection Command
-–––––––––––––––––––––––
1 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
2 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
3 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
*+ 4 /usr/java/jre1.8.0_101/bin/java
5 /opt/jdk1.8.0_102/bin/java
Enter to keep the current selection[+], or type selection number: 5
$ alternatives –install /usr/bin/jar jar /opt/jdk1.8.0_102/bin/jar 2
$ alternatives –install /usr/bin/javac javac /opt/jdk1.8.0_102/bin/javac 2
$ alternatives –set jar /opt/jdk1.8.0_102/bin/jar
$ alternatives –set javac /opt/jdk1.8.0_102/bin/javac
$ java -version
java version “1.8.0_102”
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
$ export JAVA_HOME=/opt/jdk1.8.0_102
$ export JRE_HOME=/opt/jdk1.8.0_102/jre
$ export PATH=$PATH:/opt/jdk1.8.0_102/bin:/opt/jdk1.8.0_102/jre/bin
Now when running SQLcl everything worked like a charm. Hurray :)
Originally published on Blogspot.
Comments
No comments yet. Be the first.