I've downloaded the latest com4j jars and I'm trying to run through the most simple of their examples.
I'm on Windows 7 64 bit and using a 64 bit JVM.
When I run the command (from the com4j tutorial):
java -jar tlbimp.jar -o wsh -p test.wsh %WINDIR%\system32\wshom.ocx
I get:
Exception in thread "main" java.lang.UnsatisfiedLinkError: com4j-amd64.dll: %1 is
not a valid Win32 application
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com4j.COM4J.loadNativeLibrary(COM4J.java:569)
at com4j.COM4J.<clinit>(COM4J.java:522)
at com4j.tlbimp.driver.Lib.getLibid(Lib.java:90)
at com4j.tlbimp.driver.Driver.addLib(Driver.java:38)
at com4j.tlbimp.driver.Main.doMain(Main.java:123)
at com4j.tlbimp.driver.Main.main(Main.java:56)
Exception in thread "Com4J shutdown hook" java.lang.NoClassDefFoundError: Could
not initialize class com4j.COM4J
at com4j.COM4J$3.run(COM4J.java:476)
The java code extracts "com4j-amd64.dll" next to the jar.
The latest version has just been released:
http://kohsuke.org/2012/04/27/com4j-updates/
https://github.com/kohsuke/com4j/downloads
Using this one solved all my problems.
You have two options:
Download and use the full latest version (located here:
https://github.com/kohsuke/com4j/downloads)
Extract the latest com4j-amd64.dll from the most recent version
Download the latest version (located here: https://github.com/kohsuke/com4j/downloads).
Open up the com4j.jar with your favorite zip utility (read 7zip)
Extract com4j.jar\com4j\com4j-x64.dll to the base directory of your application
(optional) Register the dll using REGSVR32 <path to dll>\com4j-x64.dll
I had a similar result at first. I found the com4j-amd64.dll that is produced by com4j is empty. The remedy is to extract the file from the com4j jar file, and put it in the relevant directory by manual action. Com4j will then not auto-produce the file since it is already there. So check if the file is empty as a first step -Carl
Related
Hello when i am running my application from Eclipse it runs perfectly but when i export it as a runnable jar, it doesn't run.
When i try running it from cmd it gives me one of 2 errors the first errror is after i just export it with the "copy required libraries into a sub-folder":
Exception in thread "main" java.lang.UnsatisfiedLinkError: no j3dcore-ogl in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at javax.media.j3d.NativePipeline$1.run(NativePipeline.java:189)
at java.security.AccessController.doPrivileged(Native Method)
at javax.media.j3d.NativePipeline.loadLibrary(NativePipeline.java:180)
at javax.media.j3d.NativePipeline.loadLibraries(NativePipeline.java:137)
at javax.media.j3d.MasterControl.loadLibraries(MasterControl.java:948)
at javax.media.j3d.VirtualUniverse.<clinit>(VirtualUniverse.java:280)
at javax.media.j3d.Canvas3D.<clinit>(Canvas3D.java:3862)
at Main.Game.<init>(Game.java:39)
at Main.Main.main(Main.java:6)
when i change the sub-folder's name from IslandDomination_lib to just lib it gives me another error:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/j3d/Canvas3D
at Main.Main.main(Main.java:6)
Caused by: java.lang.ClassNotFoundException: javax.media.j3d.Canvas3D
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
I have tried running it several ways:
1.
java.exe -jar IslandDomination.jar
2.
java.exe -cp "lib/j3dcore.jar;lib/j3dutils.jar;lib/vecmath.jar" -jar IslandDomination.jar
3. using another java program to run it for me:
package main;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException, InterruptedException{
ProcessBuilder pb = new ProcessBuilder(System.getProperty("java.home")+"\\bin\\java.exe", "-cp" , "\"lib/j3dcore.jar;lib/j3dutils.jar;lib/vecmath.jar\"" , "-jar" , "IslandDomination.jar");
pb.directory(new File("./"));
Process p = pb.start();
p.waitFor();
}
}
The internal structure of my jar consists of 4 folders:
J3DBool
Main
Maths
META-INF
The folder with the required jars is in the same folder as the main jar
You use a completely obsolete version of Java3D, which is very difficult to bundle in any software as you have to set the Java library path somehow and you have to bundle both the Java libraries and the native libraries. Rather rebuild your project with Java3D 1.6.0 pre 12, it's a lot easier to use as this version relies on JOGL 2 which uses automatic native library loading and everything is packaged as JARs, there is no longer any need of modifying the library path, just take care of the classpath.
Please follow my tutorial, especially the very last section with (a lot) more information.
Finally, the obsolete version that you use isn't guaranteed to work on any recent operating systems. If it works, you'll be lucky; if it doesn't, nobody will fix it.
I think the required library file (jar file) not found in the classpath.
you need to set Library file in your class path.
step to set class path:-
MyComputer->Properties->Advanced system setting->Environment variables
find "classpath" either in user variables area or in system variables if found edit that and put all the jar file link. if not found then create new(click on new) and put all the jar link there and try to run your application
I found out how to fix my problem and it is done by simply putting the needed dll files next to the executable jar file
I made a Java game in eclipse and when I run the executable .jar it starts up, and the loading screen starts, but then it stops and hangs. I ran it using the command line: "Java -jar filename.jar" and when the loading screen stops it displays an error. This is what the cmd shows:
E:\>Java -jar Speedrunner.jar
60Ticks, FPS:1447
60Ticks, FPS:1627
60Ticks, FPS:1380
Wed Mar 19 12:02:27 GMT 2014 INFO:Initialising sounds..
Exception in thread "Thread-2" java.lang.UnsatisfiedLinkError: no lwjgl in java.
library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.lwjgl.Sys$1.run(Sys.java:73)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:95)
at org.lwjgl.Sys.<clinit>(Sys.java:112)
at org.lwjgl.openal.AL.<clinit>(AL.java:59)
at org.newdawn.slick.openal.SoundStore$1.run(SoundStore.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at org.newdawn.slick.openal.SoundStore.init(SoundStore.java:292)
at org.newdawn.slick.Sound.<init>(Sound.java:83)
at com.daves.first_Scroller.utils.AudioPlayer.addSound(AudioPlayer.java:29)
at com.daves.first_Scroller.utils.ResourceLoader.loadSounds(ResourceLoader.java:35)
at com.daves.first_Scroller.Game.load(Game.java:110)
at com.daves.first_Scroller.Game.tick(Game.java:160)
at com.daves.first_Scroller.Game.run(Game.java:228)
at java.lang.Thread.run(Unknown Source)
This is saying that LWJGL isn't in java.library.path I've gone to my game in the workspace and configured the build path to include all the libraries and to include them in the .jar when I export my game but I'm still getting the same problem. Does anyone know what I need to do to get this to work? (I looked in the .jar and LWJGL is there in the org file)
Export lwjgl library in your jar.
To do this, right click on the project, properties, java build path, order & export, check your library
Set the (native) library path in the command line:
Java -Djava.library.path=path/to/dir -jar filename.jar
Where dir:
[...] should contain the native part (*.dll files on windows, *.so on linux,
*.jnilib on mac, etc)
(Source)
You need to do two things: you need to include the LWJGL classes on your classpath (or in your jar), and you need to include the natives in your library path.
Exporting from eclipse doesn't automatically include your library path, which is why you're getting your error.
A utility like JarSplice or SvgExe can help with both of these things.
First off. I am a newbie and green with respect to Java programming.
I created a Java Eclipse "SWT" "Application Window" on a Eclipse Kepler 4.3.1 (32-bit) running WindowBuilder and SWT (swt.jar). The design view is a composite.
The java application runs fine from Eclipse. I simply press the play button and presto.
Problem:
Issuing
java -cp . PkgNetAccelerator32.netAcceleratorApp
yields the following error message:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Composite
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Composite
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
I was doing some research and several posts on other issues suggested that the cure is to create a manifest. I saw an article that said something like:
Select the src folder, right click and select export, then Java, then JAR file, specify Manifest.jar and a path on the folder, make sure the "Generate the manifest file" is selected, and press finish.
I created the manifest file and tried launching it with the following command line:
java -jar ../Manifest.jar -cp . PkgNetAccelerator32.netAcceleratorApp
That yielded the same error message above.
I saw another article that said that one should add in the swt.jar file, but that is taken care of by the manifest. No? Specifying "swt.jar" instead of the manifest that I created resulted in an error message:
no main manifest attribute, in ../swt.jar
That error message makes sense.
I am at a loss. How do I run the java application?
I am testing on my Windows 7 Professional 64-bit desktop, but I need to run on CENTOS too. That should be no problem, as I assume whatever the fix on Windows is, will work on CENTOS.
UPDATE:
I placed the two lib files in a /lib folder to match the answer given. I then issued the following command line and got the following error message.
C:\SoftDev\Projects\NetAccelerator\JavaWorkspace\NetAccelerator32>java -cp "bin/*;lib/*" PkgNetAccelerator32.netAcceleratorApp
Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.C.<clinit>(Unknown Source)
at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source)
at PkgNetAccelerator32.netAcceleratorApp.open(netAcceleratorApp.java:43)
at PkgNetAccelerator32.netAcceleratorApp.main(netAcceleratorApp.java:33)
I found the following article, which produces a command line that works, just that is not reasonable for sending. I much rather use the answer.
Lets assume you have a eclipse project structure similar to this:
Workspace
-> Project
-> src (source code directory)
-> bin (compiled byte code directory as JAR)
-> lib (jar directory)
-> .classpath (eclipse file)
-> .project (eclipse file)
I am assuming that you are exporting the JAR as an executable JAR.
So in order to run a class in that exported JAR with another JAR from the lib directory (swt.jar) while your working directory is the Project directory you will need to execute:
java -cp "bin/*:lib/*" PkgNetAccelerator32.netAcceleratorApp
Using wildcards requires Java 6 or later
Please note: CENTOS requires : as a path separator. Windows uses a semi-colon.
This will add your classes and the swt classes onto the classpath and run your main class PkgNetAccelerator32.netAcceleratorApp
SWT 32bit vs 64bit
You will either need to use a 32bit JVM locally or continue to use a 64bit JVM and use the 64bit version of swt; see swt on windows 64 bit. I would suggest you match your version of your local JVM (32bit or 64bit) with the version that you will be running on the CENTOS machine. You will however need a different swt jar for CENTOS.
i just started working with JavaCV under MacOSX. I compiled OpenCV with CMake from the latest source and put the path where the libraries are into the -Djava.library.path=\path\to\libraries JVM Argument and added the JavaCV Libraries in my Project Settings. I also tried several other Variation of the Classpath. But when i launch an easy Project to just grab one image from my webcam i get following error:
Exception in thread "Thread-3" java.lang.UnsatisfiedLinkError: no jnivideoInputLib in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1758)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1045)
at com.googlecode.javacpp.Loader.load(Loader.java:358)
at com.googlecode.javacpp.Loader.load(Loader.java:285)
at com.googlecode.javacv.cpp.videoInputLib.<clinit>(videoInputLib.java:80)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.googlecode.javacpp.Loader.load(Loader.java:305)
at com.googlecode.javacpp.Loader.load(Loader.java:285)
at com.googlecode.javacv.cpp.videoInputLib$videoInput.<clinit>(videoInputLib.java:192)
at com.googlecode.javacv.VideoInputFrameGrabber.start(VideoInputFrameGrabber.java:89)
at webcampong.Grabber.run(Grabber.java:35)
at java.lang.Thread.run(Thread.java:680)
It is due to the compatibility issue of your openCV and javaCV libraries.
Try to download compatible openCV libraries (containing bin folder).
VideoInputFrameGrabber works only under Windows.
As stated in JavaCV's README.txt:
New videoInputLib wrapper and corresponding VideoInputFrameGrabber to capture using DirectShow, useful under Windows 7 where OpenCV and FFmpeg can fail to capture using Video for Windows (issue #58)
I use javacpp and videoinput to manipulate cameras. I got the error 'java.lang.UnsatisfiedLinkError: no jnivideoInputLib in java.library.path' when I call 'videoInput.listDevices()'.
I fix the problem by adding codes like:
org.bytedeco.javacpp.Loader.load(org.bytedeco.javacpp.opencv_highgui.class);
System.out.println(videoInput.listDevices());
you must call 'Loader.load' first before you call other methods, I don't know why.
I'm currently following the third tutorial listed here: here
where I'm trying to compile some matlab code into Java classes. Creating a project in eclipse, and correctly linking the libraries (exactly how its done in the tutorial). Everything actually compiles, but when I run the program I get an Unsatisfied Link error.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: C:\Program Files\MATLAB\R2009b\bin\win32\BuilderJABootstrap.dll
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.<clinit>(MWMCR.java:1571)
at com.demo.DemoMCRFactory.<clinit>(DemoMCRFactory.java:100)
at com.demo.MLTestClass.<init>(MLTestClass.java:62)
at Driver.main(Driver.java:16)
The troubling part is the Can't load library: as the path provided '\win32' is not a legitimate path on my computer as I have a 64 bit machine, so the dll is located at \win64. However, I've triple checked all my Environmental variables and am kind of stuck. Could I be using a 64-bit version of matlab, with a 32-bit library?
Thanks!
ChrisH's solution was it