I am accessing an executable .jar file from vb.net and I am getting a com.ibm.db2.jcc.am.SQLException Failure in loading native library db2jcct2, no db2jcct2 in java.library.path. But When I am executing same jar directly from my system it is executing fine and is connecting to the database well.

The java code is as follows:

url is built as follows (Note there is no space between ':' and 'port'. It was converting it to a smiley hence I inserted a space here) :
jdbc:db2://server: port/dbalias:user=user;password=password;";
Java code

System.out.println("**** Loaded the JDBC driver");

con = DriverManager.getConnection(url);
// Commit changes manually;
System.out.println("**** Created a JDBC connection to the data source");

stmt = con.createStatement();
System.out.println("**** Created JDBC Statement object");

rs = stmt.executeQuery("SELECT emp_no FROM tablename FETCH FIRST ROW ONLY");
System.out.println("**** Created JDBC ResultSet object");

while (rs.next()) {
empNo = rs.getString(1);
System.out.println("Employee number = " + empNo);

System.out.println("**** Closed JDBC Statement");

System.out.println ( "**** Transaction committed" );


This code is executing perfectly fine when I execute the jar. I have inlcuded db2jcc.jar in the class path and build path.

Code for executing this jar file from vb.net is as follows:

jarfile = "myjar.jar "
jarpath = "C:\Users\myid\mypath\"

Dim processinfo As New ProcessStartInfo()
processinfo.WorkingDirectory = "C:\"
processinfo.FileName = "java.exe"
processinfo.Arguments = "-jar " + jarpath + jarfile
Dim myProcess As New Process()
processinfo.UseShellExecute = False
processinfo.RedirectStandardOutput = True
processinfo.RedirectStandardError = True
myProcess.StartInfo = processinfo
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
myProcess.StartInfo.CreateNoWindow = True

Dim myStreamReader As System.IO.StreamReader = myProcess.StandardOutput
Dim myStreamErr As System.IO.StreamReader = myProcess.StandardError
' Read the standard output of the spawned process.
Dim myString As String
Dim msgout As String = Nothing
myString = myStreamReader.ReadLine()
msgout += myString + vbCrLf
Loop Until (myStreamReader.EndOfStream)

myString = myStreamErr.ReadLine()
msgout += myString + vbCrLf
Loop Until (myStreamErr.EndOfStream)


While executing this code it starts looking for native library db2jcct2.

Any help is appreciated!! Many Thanks!!

Peeyush Gera