Skip to Main Content

SQLcl

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

SQLcl.exe giving Java error Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not loa

1002330Jan 30 2018 — edited Aug 17 2018

Hello Folks,

I am trying to connect sqlcl to our database but its giving me the error below -

Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load library. Reasons: [no jansi in java.library.path, Access is denied]

        at org.fusesource.hawtjni.runtime.Library.doLoad(Library.java:182)

        at org.fusesource.hawtjni.runtime.Library.load(Library.java:140)

        at org.fusesource.jansi.internal.CLibrary.<clinit>(CLibrary.java:37)

        at oracle.dbtools.raptor.console.clone.DbtoolsConsoleReader.<init>(DbtoolsConsoleReader.java:245)

        at oracle.dbtools.raptor.console.clone.DbtoolsConsoleReader.<init>(DbtoolsConsoleReader.java:238)

        at oracle.dbtools.raptor.console.SQLPlusConsoleReader.<init>(SQLPlusConsoleReader.java:35)

        at oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.startConsole(SqlCli.java:235)

        at oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.<init>(SqlCli.java:216)

        at oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.main(SqlCli.java:427)

I have jre1.8.0_161 folder in the sqlcl folder. I have got the Java_Home link to sqlcl/jre1.8.0_161 and I in my path variable i have added %JAVA_HOME%\bin. I am lost at why its giving me this error. Any help is appreciated. Thank you!

Comments

Gary Graham-Oracle

SQLcl will first look for the existence of sqlcl\jre, not sqlcl\jre<specific_version>. So you need something like...

SQLclWithEmbeddedJRE.jpg

The list of rules are in , shown below for convenience (Windows)...

1. If a JRE is copied into a sqlcl\jre folder, then SQLcl uses that Java version.

2. Otherwise, running sql.bat uses an explicitly set JAVA_HOME, followed by the Java version appearing first in PATH.

3. Otherwise, running sql.exe first checks the Windows Registry for which Java version to use, then falls through to the rules in (2).

Gary Graham-Oracle

In addition, make sure your SQLcl install contains the file jline.jar in the sqlcl\lib directory.  That is where the jansi stuff resides.  Perhaps the utility you used to extract from the sqlcl zip did not do the job properly.

1002330

Thank you Gary for the response. I checked for jline.jar and it is there. Please forgive me for my silly question but here it goes - In your first comment you mentioned JRE should be in the path of SQLcl and that makes sense. I changed the name of JRE folder to just "JRE" instead of JRE<version>, however, should the SQLcl's lib and bin files reside IN the JRE bin files? That doesn't make sense right? I guess I am confused in where the SQLcl's lib & bin files should reside in order for it to work. Again, thanks for your help!

Gary Graham-Oracle

No worries. I also should have provide this screenshot of the folder structure at the next level up, the level where the embedded jre folder is a sibling of the lib and bin folders that come with SQLcl. The jre, of course, has its own bin and lib folders, as shown in my prior post.

SQLclWithEmbeddedJREasSiblingToSQLclBin+Lib.jpg

So renaming that JRE<version> to simply JRE is what I intended.

1002330

Thanks for the response Graham. I re installed/extracted SQLcl to my program files. Grabbed JRE folder and stuck it as a sibling in the SQLcl folder like this:

pastedImage_1.png

And then went to the SQLcl's bin folder where my sql.exe and sql.bat files are residing and tried to run sql but I get the same error.

pastedImage_0.png

1002330

I have SQLDeveloper set up and it works fine. I read somewhere that sqlcl comes with the developer and so I started looking for it and there it was. The sql.exe and sql.bat files were in my C:\Program Files\sqldeveloper\sqldeveloper\bin folder. So I tried to run it from there and I got the same error as above. This is very strange!

1002330

Here is the screenshot:

pastedImage_0.png

Gary Graham-Oracle

I agree, this is very strange. I have a superstition about never installing SQLcl or SQL Developer under C:\Users or C:\Program Files, but I doubt that is causing you any problems because I can launch SQLcl in either scenario...

SQLclLaunchFromProgramFiles.JPG

And if you actually could open SQLcl successfully and run the show java command, you would see jline.jar in the ClassPath...

SQLclShowJava.jpg

There must be something configured incorrectly in your environment, but I am at a bit of a loss what that might be.

Gary Graham-Oracle

As an alternative, you might want to try launching SQLcl with the sql.bat command.  And, in fact, I do see something strange in your last screenshot:  why is sql.exe dated today at 01/31/2018 9:15 AM?

1002330

Tried sql.bat - a window comes up for less than a second and goes away. I think since I tried to run sql.exe today its dating today.

Gary Graham-Oracle

Oh, sorry, I forgot about a prior forum discussion on that problem.  If you just run sql.bat from the command line you will see...

C:\Program Files\sqlcl\bin>sql.bat

Environment variable echo on not defined

The syntax of the command is incorrect.

That other discussion describes in detail a fix for that issue (and others) with the bat file...

Errors in sql.bat 17.4.0.354.2224

As for the Modified Date of the sql.exe changing after running it, I do not see that happen on my system. Most likely something "special" going on in your environment.

MayhemXTC

I found that this was caused in my env by /tmp being secured and not having execute permission. I resolved this (for me) by setting the tmp location to a different directory (my preference was within the current directory).

I did this by editing the the sql binary (sqlcl/bin/sql) in two places :

FIRSTLY:

function setupArgs {

#

# Standard JVM options which are always used

#

AddVMOption -Djava.awt.headless=true

AddVMOption -Dapple.awt.UIElement=true

AddVMOption -Xss10M

AddVMOption -Djava.io.tmpdir=$TMPDIR

}

SECONDLY, right at the bottom of the file:

checkADE

PWD=`pwd`

TMPDIR="$PWD/tmp"

if [ ! -d $TMPDIR ]; then

  mkdir $TMPDIR

fi

setupArgs

...

..

.

This had me stumped for a while, so I hope its helpful to someone 

1 - 12

Post Details

Added on Jan 30 2018
12 comments
2,792 views