B4J Question Any way to bundle jdbc jars?

B4JExplorer

Active Member
Licensed User
Longtime User
Hi,

I'm able to execute code that accesses an Oracle database, using the AdditionalJar ojdbc6.jar. That's in Debug mode.

But when I set it to Release mode, it's apparently not able to locate the ojdbc6.jar. That happens inside the ide, or from the command line.

I noticed in the generated jar, that ojdbc6.jar isn't included. Which means that I would have to refer to it on the classpath.

Is there any way to bundle the AdditionalJar inside the generated Release Jar?


I know that Launch4J can generate Windows executables. Can it also generate standalone jars?
 

B4JExplorer

Active Member
Licensed User
Longtime User
Have you set #MergeLibraries to true? It should embed the additional jars in the compiled jar. See DBUtils for example.

Yep, it's set to true. I had seen the DbUtils post and replicated that. But it's still missing the ojdbc6.jar.

Also, the Additional Libraries path is set to the folder where ojdbc6.jar resides.
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
Yep, it's set to true. I had seen the DbUtils post and replicated that. But it's still missing the ojdbc6.jar.

Also, the Additional Libraries path is set to the folder where ojdbc6.jar resides.

To clarify further, the error

java.sql.SQLException: No suitable driver found for jdbc:eek:racle:thin:mad:....

is occurring. It happens in Release mode, and from the command line. But it does not happen, in Debug mode.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
See my answer in post #4.

This is how the compiled jar file looks:
SS-2014-05-20_15.43.44.png


SQLite jar classes are available under org folder.
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
Ok, so it actually pulls out the classes from the additional jars, and throw them in the main jar.

Yep, they seem to be inside my generated jar. So the reason for the 'no suitable drive' message, is something else.

Maybe Oracle uses a native dll, which isn't available in the Release mode paths. I'll look around, thanks.
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
If #MergeLibraries is set to false, then Release mode works in the IDE.

However, on the command line - After creating a libs folder in the generated jar file, and copying the additional jars which were referenced in the manifest, the command line now returns a

java.lang.NoClassDefFoundError: anywheresoftware/b4a/BA

error.


Exception in thread "main" java.lang.NoClassDefFoundError: anywheresoftware/b4a/BA
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
at java.lang.Class.getMethod0(Class.java:2774)
at java.lang.Class.getMethod(Class.java:1663)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: anywheresoftware.b4a.BA
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 6 more
 
Upvote 0
Top