Can't load Java Library - java

I am very new to Java and I am trying to run a program I got from a friend. I keep getting this error and I'm unsure how to solve the problem.
Application is starting. Fetching data. Please wait... (approx. 10s)
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-cocoa-4236 in java.library.path
no swt-cocoa in java.library.path
Can't load library: C:\Users\Andrew.swt\lib\win32\x86_64\swt-cocoa-4236.dll
Can't load library: C:\Users\Andrew.swt\lib\win32\x86_64\swt-cocoa.dll
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:331)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:240)
at org.eclipse.swt.interal.C.<clinit>(C.java:21)
at org.eclipse.swt.widgets.Display.<clinit>(Display.java:101)
at view.MainWindow.open(MainWindow.java:77)
at view.MainWindow.main(MainWindow.java:65)
Apparently I'm missing the SWT library (swt-cocoa-4236 and/or swt-cocoa?), but I have no idea where to get it. That statement probably reveals my ignorance. If anyone could even point me in the right direction to where I might be able to solve the problem I'd be very grateful. Thanks!

Seems like the program that you are running is not built for your OS. SWT is OS dependant and JVM depedant. All SWT programs will use swt.jar which will be different based on the underlying OS. The one the program is using is built for Mac OS and seems like you are running that on a non-Mac system.
Regarding 'How to solve it', it depends on how the program that you are running is packaged.
Check the java version you are using and download appropriate SWT jar file.

I think Mubin (i.e. the above answer) is correct. here is where you can download the specific version of SWT.jar for your environment http://www.eclipse.org/swt/.
(I am answering your question for "I have no idea where to get it.")

little late to the game, but i just had the same problem and found this solution:
Here's what worked for me:
Right Click on your Project Folder of your HelloWorldSWT Project-> Properties -> Java Build Path -> Tab 'Projects'
Expand the 'org.eclipse.swt.cocoa.macosx.x86_64' folder by clicking on the arrow left to it
Select 'Native library location' and click Edit
Click the Workspace Button and select 'org.eclipse.swt.cocoa.macosx.x86_64', then click ok (serveral times).
That did the trick ... Ma-an

Related

Netbeans/java: Could not find or load main class library

I'm trying to setup my development environment on Linux Mint after an unfortunate reinstall of my whole computer due to some windows troubles. For the development of the Java program I use Netbeans. I allready installed all dependencies and external libraries. However when I'm trying to run the program I get the following output:
ant -f /home/***/Documents/ebart/git/projecten/nedap/Next -Dnb.internal.action.name=run run
init:
Deleting: /home/***/Documents/ebart/git/projecten/nedap/Next/build/built-jar.properties
deps-jar:
Updating property file: /home/***/Documents/ebart/git/projecten/nedap/Next/build/built-jar.properties
compile:
run:
Error: Could not find or load main class library
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
I already tried to make it work with openJDK, orcacle(normal) JDK, Ubuntu 15.04, Linux Mint, Netbeans 8.0.2, Netbeans 7.0...?1 or 2? but it doesn't make a difference. Also google couldn't provide me with a solution.
The strange thing is that my main class is called "Next" and I'm fairly sure that I selected the right Main Class (com.bata.ebart.next.Next). I suppose it has something to do with that java cannot find its main libraries(http://en.wikipedia.org/wiki/Java_Class_Library) but I'm not sure about that. Also I am not into that and therefore I have no clue what to do.
Does someone know how to solve this issue or help me in the right direction?
Right click project in Projects. Select Properties. In the Categories select Run. For the Main Class option click browse and select the correct Main Class. Then try rebuilding your project and running it.
And the solution lays in a VM Options. I already added the VM Option -Djava library path="/usr/lib/jni/" to make librxtx-java work (according to this post). Removing this VM Options fixed my problem. I haven't tested if I still can connect to my serial device (the reason why I'm using librxtx-java) because I don't have my serial device over here.

No LeapJava in java.library.path

I'm encountering a problem with the build of my JavaFX project with the Leap Motion.
When I run the file.jar, the application's window is opening, but when I call the leap motion, it's not working any more.
I have the following error :
Native code library failed to load.
java.lang.UnsatisfiedLinkError: no LeapJava in java.library.path
Yet, I have configured the buildpath. I have added the leapJava.jar, with the native library x64.
I don't understand why it doesn't work ?
Anyone with an idea ?
Thanks
The LeapJava.dll is missing or the Java library path is not set up correctly. Please have a look at the docs - setting up a project:
https://developer.leapmotion.com/documentation/java/devguide/Project_Setup.html
I have followed each step in the Eclipse section. :/
Firstly, since you haven't mentioned any specification about your system, I am answering this in context with a 64 bit Ubuntu machine.
You will posses a libLeap.so and a libLeapJava.so in 'YourDeveloperKitDirectory'/LeapSDK/lib/x64/ . These files should be copied to your /usr/lib and the configuration/bulid path (if using IntelliJ IDE -> 'Edit Configurations'->'Application'->'configuration'->'VM options'->"-Djava.library.path=/usr/lib") should be appropriately stated.
Save and run your application.
I had this problem, what solved it was adding -Djava.library.path=/Path/to/LeapDeveloperKit_2.3.1+31549_mac/LeapSDK/lib to the command line call for the .jar file. (make sure your developer kit is the right version)
So rather than:
java -jar leapMotionProgram.jar
It had to be:
java -jar -Djava.library.path=/Path/to/LeapDeveloperKit_2.3.1+31549_mac/LeapSDK/lib leapMotionProgram.jar

Java: Missing libraries

I'm a bit new to Java / Processing and I opened up a project/workspace with the following errors:
is missing required library: '/Applications/Processing.app/Contents/Resources/Java/libraries/javamail/smtp.jar'
/javamail/dsn.jar
/javamail/mailapi.jar
/javamail/pop3.jar
I have the Processing app installed, but it's been a while...do I just need to upgrade processing or is there another place I need to go to get these .jar files?
I'm using Eclipse and there seems to be quite a list of referenced jar files (some broken)
It's telling you that there used to be a library at
/Applications/Processing.app/Contents/Resources/Java/libraries/javamail/smtp.jar
but it's no longer there, or possibly you opened a project that somebody else edited on a different machine where things were laid out differently.
Open the project build-path dialog and make sure all the libraries point to the correct locations.
If the problem still persist, try doing clean and build in eclipse. It might help.

no ocijdbc10 in java.library.path

So I've been plagued by this issue, whenever I try to run my app in eclipse, I get this error.
2011-02-23 09:55:08,388 ERROR (com.xxxxx.services.factory.ServiceInvokerLocal:21) -
java.lang.UnsatisfiedLinkError: no ocijdbc10 in java.library.path
I've tried following the steps I found here with no luck. I've tried this on a XP VM as well as windows 7 (although in win 7 I get a different error, below)
java.lang.UnsatisfiedLinkError: no ocijdbc9 in java.library.path
I've made sure my oracle client was ok (by running TOAD) and I also re-added the classes12.jar / ojdbc14.jars to my WEB-INF/lib folder taken directly from my %ORACLE_HOME% folder (also re-added them to the lib path). I've also tried just adding the ojdbc14.jar without the classes12.jar. Any suggestions appreciated.
In the XP VM I have my PATH variable set to C:\Program Files\Java\jdk1.6.0_24\bin;C:\ORACLE\product\10.2.0.1\BIN. I'm using Tomcat server 5.0
I agree with the advice you've gotten in the comments to use the thin driver instead of the OCI driver if you can. It is simpler and it should bypass the problem you're having.
If you do need the OCI driver for some reason, your problem is that the DLLs are not on your Java library path. This is separate from the classpath that is used to locate class definitions. The clues here are (a) the fact that the error references java.library.path, and (b) the fact that you are getting an UnsatisfiedLinkError rather than a ClassNotFoundException.
You would need to set your java.library.path property to include the location of the DLLs, or add the location of the DLLs to the Windows PATH, in order for Java to locate them.
More information here: http://forums.oracle.com/forums/thread.jspa?threadID=615281
I have encountered this same error twice recently. The first time I managed to resolve it without knowing exactly what I did. Don't you just hate that because when it shows up again what do you do? Well it did show up again when I had to create a new project in eclipse. This time I know what the problem was and it is a very simple thing to overlook and fix. The other posters have great information but it won't help you if you have the same root cause that I had and I believe that you do...
The issue was simple and it was this: I had two different ojdbcXX.jar files in my Java buildpath (within Eclipse). I had both ojdbc14.jar and ojdbc6.jar Apparently it was hitting ojdbc14.jar first and then throwing the error. Once I removed the unnecessary jar file then the error went away. Drove me crazy for an entire day before I realized what was wrong!
I hope this helps.
This error occurs when you have a wrong/older version of oci.dll. After setting the path and reverting to the correct oci.dll, the error went away.
I also meet this error when i use DBvisualize to connect Oracle database.
I think it is because you have not yet installed Oracle Client.
After installing it, maybe it is ok
I had the same problem while using MyEclipse. One needs to set the path to oracle clients lib and bin folder. Attaching image for reference. Hope it helps
enter image description here

Configuring Netbeans with JNotify

I'm trying to use the JNotify library along with netbeans, however I don't know the proper way to configure it. Everything I try, the lines involving jnotify (eg. import net.contentobjects.jnotify.*) are underlined in red. Google seems to show nothing helpful regarding netbeans with jnotify, although I assume it's something simple like adding it to the classpath. I've tried adding the .jar as a library for compile & for run, no go.
The line i've been provided for running my app from the jnotify page:
-cp jnotify.jar -Djava.library.path=.
should I be using this as my compiling options or VM run options or both? seeing as I don't want to have to distribute my app with a .dll or .so file or the jnotify .jar.
Everyone on this site recommends using such and such a library, but they don't realize how hard they can be to set up (jnotify,boost,curl), and most who recommend them have probably never even used them themselves.
You're right, you have to add every library you use in your programs, into the projects classpath:
Click on the project node in your 'Projects' window. It should by default have a node called 'Libraries'.
Right click this node and select 'Add JAR/Folder'
Locate the JNotify.jar on the file dialog and press 'Open'.
Refresh your project, or just give netbeans some time to rescan the classpath, and you should be good to go.
There definately is something wrong with your classpath. While the above is exactly how you set the classpath when running a Java program, its different for a NetBeans project.
Follow these articles on how to add extenal jars to a NetBeans project.

Categories

Resources