Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Executing without the need for -Djava.library.path
Executing without the need for -Djava.library.path [message #437171] Sun, 30 May 2004 17:22 Go to next message
Eclipse UserFriend
Originally posted by: swt.cloudnine.net.nz

Hello,

I've built a JAR with the relevant Class-Path attribute in it's manifest,
and I'm currently attempting to have some 'bootstrap' code setup
java.library.path before the Eclipse/SWT classes are loaded.

It's not working :-(
Using the following code:

static {
String systemLibraryPath = System.getProperty(JAVA_LIB_PATH);

// Setup the library paths
String currentDir = System.getProperty("user.dir"); File libPath =
new File(currentDir, "lib/swt/linux"); String libraryPath =
libPath.getAbsolutePath(); if (systemLibraryPath != null &&
systemLibraryPath.length() > 0) {
systemLibraryPath = libraryPath + File.pathSeparator +
systemLibraryPath;
}

System.setProperty(JAVA_LIB_PATH, systemLibraryPath);
System.out.println("Setting java.library.path to " +
systemLibraryPath);
}

(it's not platform independent yet, that will come later). Now, this spits
out:

neil@samson:~/devel/da4/build/dist/client/linux$ java -jar main.jar
Setting java.library.path to
/home/neil/devel/da4/build/dist/client/linux/lib/swt/linux:/ home/neil/java/j2sdk1.5.0/jre/lib/i386/client:/home/neil/jav a/j2sdk1.5.0/jre/lib/i386:/home/neil/java/j2sdk1.5.0/jre/../ lib/i386
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:494) at
tcdc.da4.console.gui.Boot.main(Boot.java:34)
Caused by: java.lang.UnsatisfiedLinkError: no swt-pi-gtk-3044 in
java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1668) at
java.lang.Runtime.loadLibrary0(Runtime.java:817) at
java.lang.System.loadLibrary(System.java:986) at
org.eclipse.swt.internal.Library.loadLibrary(Library.java:10 0) at
org.eclipse.swt.internal.gtk.OS.<clinit>(OS.java:19) at
org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java: 63) at
org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java: 54) at
org.eclipse.swt.widgets.Display.<clinit>(Display.java:112) at
tcdc.da4.console.gui.ShellBeanFactory.getBean(ShellBeanFacto ry.java:19)
at
tcdc.da4.console.gui.SpringBeanFactory.getGUIBeanFactory(Spr ingBeanFactory.java:25)
at
tcdc.da4.console.gui.Main$SpringyViewContainer.verifyConnect ion(Main.java:114)
at tcdc.da4.console.gui.Main.open(Main.java:45) at
tcdc.da4.console.gui.Main.main(Main.java:31) ... 5 more

And If I run the application by cutting and pasting the FIRST path in the
java.library.path (the one to .../swt/linux), the application DOES run. So
I know that the path is right, and I can see that it is being set, and
it's being set BEFORE the loadLibrary call is attempted - but it still
doesn't work!

arg.

Any ideas?

I noticed in ClassLoader, that it does cache java.library.path upon the
first call to loadLibrary, but I've been to find a way to confirm that
this is happening. In my attempts to load as few classes/libraries as
possible, I even resorted to loading and running the real code using
reflection, so that I couldn't possibly be causing the problem by other
static initializers. Well, that didn't work either :-(

Any ideas?

Cheers,
Neil Clayton

Neil
Re: Executing without the need for -Djava.library.path [message #437187 is a reply to message #437171] Mon, 31 May 2004 15:23 Go to previous messageGo to next message
David Thomson is currently offline David ThomsonFriend
Messages: 65
Registered: July 2009
Member
String dir = "/home/david/";

System.setProperty("java.library.path",dir);

works for me. Also, make sure you have the right versions, i.e. 3044
exactly or it won't work.
Re: Executing without the need for -Djava.library.path [message #437188 is a reply to message #437171] Mon, 31 May 2004 15:25 Go to previous message
David Thomson is currently offline David ThomsonFriend
Messages: 65
Registered: July 2009
Member
Also make sure *all* the jar files distributed with the linux swt
package are included in your classpath, inc. mozilla + gtk-pi.

David
Previous Topic:How can I capture global hotkey?
Next Topic:Enter key down event problem
Goto Forum:
  


Current Time: Thu Apr 25 22:32:43 GMT 2024

Powered by FUDForum. Page generated in 0.03607 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top