UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 7th, 2006, 09:30 AM
scooterp83 scooterp83 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 206 scooterp83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 57 m 12 sec
Reputation Power: 6
Exception in thread "main" java.lang.UnsatisfiedLinkError: ocijdbc9

I am trying to run a shell script in Unix and I am getting the following error:

Quote:
Exception in thread "main" java.lang.UnsatisfiedLinkError: ocijdbc9 (Not found i
n java.library.path)
at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:949)
at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:918
)
at java.lang.System.loadLibrary(System.java:451)
at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:267)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:365)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
va:547)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:347)
at java.sql.DriverManager.getConnection(DriverManager.java:562)
at java.sql.DriverManager.getConnection(DriverManager.java:186)


I have researched online and found out that it might be caused by my enviorment variables however I set the following variables and it still does not work:

Quote:
ORACLE_HOME=c:\oracle\ora91
CLASSPATH=......%ORACLE_HOME%\jdbc\lib;
PATH=......%ORACLE_HOME%\lib;


Reply With Quote
  #2  
Old July 7th, 2006, 04:09 PM
stdunbar stdunbar is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: May 2004
Location: Superior, CO, USA
Posts: 1,730 stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 23 h 23 m 44 sec
Reputation Power: 375
Send a message via ICQ to stdunbar Send a message via Yahoo to stdunbar
Wait - are you on Unix or Windows? You're trying to use a DOS syntax on Unix and it won't work. Do you really have a C: drive in Unix?

If you really are on Unix you need to learn a bit about it. First things first - the directory separator should lean forward, not backward. Secondly, Unix environment variables are prefixed with the $ character, not surounded by the % character like in dos.

But the real problem you have is that your Java program cannot load the Oracle shared library. Unlike Windows Unix does not find shared libraries based on the PATH environment variable. Rather it uses another one. The name depends on the Unix you're on. For example, under Solaris and Linux the environment variable LD_LIBRARY_PATH is used. 64 bit Solaris uses LD_LIBRARY_PATH_64. HP/UX uses something somewhat different (depending on if your in a 32 or 64 bit O/S) and so on.

What Unix are you running? Assuming Solaris/Linux for a second you'll want to have something like:

Code:
export ORACLE_HOME=/where/ever/oracle/is/installed
export CLASSPATH=$ORACLE_HOME/jdbc/lib
export LD_LIBRARY_PATH=$ORACLE_HOME%/lib


It is important to note that under Unix the CLASSPATH separator is the colon character - : - not the semicolon. Same with the other separators. So if you have multiple things on any of the above environment variables have them delimited with a colon.
__________________
Need Java help? Want to help people who do? Sit down with a cup of Java at the hotjoe forums.

Reply With Quote
  #3  
Old July 10th, 2006, 09:19 AM
scooterp83 scooterp83 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 206 scooterp83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 57 m 12 sec
Reputation Power: 6
Im actually running it on an AIX operating system.

Here are my export statements.
Quote:
export ORACLE_HOME=/users/oracle/product/9.2.0
export LD_LIBRARY_PATH=$ORACLE_HOME%/lib
export PATH=$PATH:$ORACLE_HOME/bin


When I run the shell script it still does not pick up the new variables. Any ideas?

Reply With Quote
  #4  
Old July 10th, 2006, 09:54 AM
stdunbar stdunbar is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: May 2004
Location: Superior, CO, USA
Posts: 1,730 stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 23 h 23 m 44 sec
Reputation Power: 375
Send a message via ICQ to stdunbar Send a message via Yahoo to stdunbar
AIX uses LIBPATH instead of LD_LIBRARY_PATH. And I'd guess that the trailing % sign was a typo?

Reply With Quote
  #5  
Old July 10th, 2006, 10:14 AM
scooterp83 scooterp83 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 206 scooterp83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 57 m 12 sec
Reputation Power: 6
how about the PATH variable....whats the diff from PATH and CLASSPATH?

Thanks

Reply With Quote
  #6  
Old July 10th, 2006, 11:18 AM
stdunbar stdunbar is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: May 2004
Location: Superior, CO, USA
Posts: 1,730 stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 23 h 23 m 44 sec
Reputation Power: 375
Send a message via ICQ to stdunbar Send a message via Yahoo to stdunbar
CLASSPATH is a Java specific thing. It tells the Java virtual machine where to look for Java libraries. PATH is used by the shell to located executables.

As a general statement I wouldn't use the CLASSPATH environment variable. You're much better off using the -classpath option to the Java command. I would personally have a shell script that does something like (obviously the path names may be different)

Code:
#!/bin/bash
...

export JAVA_HOME=/usr/java
export ORACLE_HOME=/users/oracle/product/9.2.0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
$JAVA_HOME/bin/java -classpath $ORACLE_HOME/jdbc/lib:/anything/else the.java.package.and.ClassName


or something like this. The problem is that CLASSPATH is global - any Java program you run will pick this up. To minimize the possibility of any issues I don't like to set it.

Reply With Quote
  #7  
Old July 10th, 2006, 11:30 AM
scooterp83 scooterp83 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 206 scooterp83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 57 m 12 sec
Reputation Power: 6
Ok but instead of LD_LIBRARY_PATH...you would want LIBPATH. Right?

Reply With Quote
  #8  
Old July 10th, 2006, 11:40 AM
stdunbar stdunbar is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: May 2004
Location: Superior, CO, USA
Posts: 1,730 stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 23 h 23 m 44 sec
Reputation Power: 375
Send a message via ICQ to stdunbar Send a message via Yahoo to stdunbar
Quote:
Originally Posted by scooterp83
Ok but instead of LD_LIBRARY_PATH...you would want LIBPATH. Right?


Duh - yeah - too many years on Solaris systems

Reply With Quote
  #9  
Old July 10th, 2006, 11:46 AM
scooterp83 scooterp83 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 206 scooterp83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 57 m 12 sec
Reputation Power: 6
I have made these changes however i can not test them yet because now the UNIX box is down...lovely...but technically these changes should fix the problem right? I only ask this because i was reading somewhere online that when you run a shell script it actually makes a child shell where it runs and therefore the env variables can only be seen in the child shell and not the parent. Therefore when the classpath looks for the oracle driver it looks in the parent shell and does not find it. Does this make any sense? Or was that person totally making this up? Thanks

Sorry im a newbie with this stuff and i appreciate your help

Reply With Quote
  #10  
Old July 10th, 2006, 11:56 AM
stdunbar stdunbar is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: May 2004
Location: Superior, CO, USA
Posts: 1,730 stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 23 h 23 m 44 sec
Reputation Power: 375
Send a message via ICQ to stdunbar Send a message via Yahoo to stdunbar
That is what the export command does - it exports it to other shells.

But an important caveat - the syntax I gave is bash or korn shell (ksh). If you are using a different shell then the programming syntax is a bit different. For example, if you're using the "normal" borne shell (/bin/sh) then the syntax is:

Code:
JAVA_HOME=/usr/java
export JAVA_HOME


and so on. If you're trying to write a very portable shell script then you will want to use this syntax (something some Linux developers miss). If you don't care and just want it to run on your AIX machine then I'd use bash/ksh syntax like I showed before.

Reply With Quote
  #11  
Old July 10th, 2006, 12:03 PM
scooterp83 scooterp83 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 206 scooterp83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 57 m 12 sec
Reputation Power: 6
Yea i am doing it that way. I am also defining variables in its own properties file and then sourcing that file. Im doing this so that all i have to change is the prop file inorder to change the variables.

Reply With Quote
  #12  
Old July 10th, 2006, 12:10 PM
scooterp83 scooterp83 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 206 scooterp83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 57 m 12 sec
Reputation Power: 6
Here is what i have:

properties file
Code:
.
.
.
ORACLE_HOME=/users/oracle/product/9.2.0
LIBPATH=$LIBPATH:$ORACLE_HOME/lib
PATH=$PATH:$ORACLE_HOME/bin
CLASSPATH=$CLASSPATH:$ORACLE_HOME/lib:$ORACLE_HOME/bin
.
.
.


shell script
Code:
#!/usr/bin/ksh

# Source the properties file
. $PWD/ococ011d.prop;

export PATH
export LIBPATH
export ORACLE_HOME
.
.
.
.
! ${JAVA_HOME}/bin/java -classpath $CLASSPATH $JAVA_ARGS $PROG_NAME


Technically this should work...i think

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Exception in thread "main" java.lang.UnsatisfiedLinkError: ocijdbc9


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |