I want to export my Java project to a standalone Jar or exe file. I use blueJ as an IDE and I use following libraries: GLOOP, JOGL and GlueGen (aswell as pi4j). Running the program in the IDE itself works flawlessly, however when I export the program as a .jar file and wrap it into an exe with Launch4j I get following error:
Catched IllegalArgumentException: No Jar name in <jar:file:/C:/Users/neche/Desktop/UfoSpiel.exe!/com/jogamp/common/os/Platform.class>, got <UfoSpiel.exe>, while TempJarCache.bootstrapNativeLib() of null (null + null)
Exception in thread "main" java.lang.UnsatisfiedLinkError: no gluegen-rt 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 com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoaderBase.java:454)
at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:59)
at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:90)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:328)
at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrary(DynamicLibraryBundle.java:390)
at com.jogamp.common.os.Platform$2.run(Platform.java:249)
at java.security.AccessController.doPrivileged(Native Method)
at com.jogamp.common.os.Platform.loadGlueGenRTImpl(Platform.java:231)
at com.jogamp.common.os.Platform.<clinit>(Platform.java:183)
at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:99)
at GLOOP.GLRenderer.<init>(GLRenderer.java:90)
at GLOOP.GLKamera.<init>(GLKamera.java:49)
at UfoSzene.main(UfoSzene.java:14)
I use the Operating system Windows 64bit and BLuej version 414
I have googled a lot but never found someone who had the same problem or used the same OS or IDE.
It would be amazing if anyone of you could help.
Here is the main thread code:
import GLOOP.*;
public class UfoSzene
{
public static void main(String[] args)
{
GLKamera kamera;
GLLicht licht;
GLBoden weltall;
UfoSpiel ufoSpiel = new UfoSpiel();
Punkte punkteStand = new Punkte();
weltall = new GLBoden("Weltall.jpg");
kamera = new GLKamera(800,800);
kamera.setzePosition(2000,3001,20);
kamera.setzeBlickpunkt(2000,0,0);
licht = new GLLicht();
ufoSpiel.start();
punkteStand.start();
}
}
Thanks in advance!
Related
I made libcc.so from my test.cpp in ubuntu, and the content of test.cpp is linked with ffmpeg and opencv libraries. After making the libcc.so, it's loaded in JNItest2.java.
JNItest2.java:
public class JNItest2 {
public native void helloworld();
static{
String libPath= "/home/sun/workspace/JNItest2/src";
System.setProperty("java.library.path",libPath);
String Path = System.getProperty("java.library.path");
System.out.println("java.library.path=" + Path);
System.loadLibrary("cc");
}
public static void main(String[] args){
new JNItest2().helloworld();
}
}
However, JNItest2.java can run on Eclipse, the exported jar file can't run in terminal.
Error Message in terminal:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no test in
java.library.path at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) at
java.lang.Runtime.loadLibrary0(Runtime.java:870) at
java.lang.System.loadLibrary(System.java:1122) at JNItest2.<clinit>
(JNItest2.java:23)
Does anyone help me to solve this problem?
Thanks, Hsiu
Take a look here for a sample related to JNI development:
http://jnicookbook.owsiak.org/recipe-No-001/
This is a very simple app where you can take a look at all required elements for running JNI based codes.
In your case:
make sure to put so file in LD_LIBRARY_PATH
if you want to use ffmpeg stuff in your code make sure to check out these two samples as well:
http://jnicookbook.owsiak.org/recipe-No-018/
https://github.com/mkowsiak/jnicookbook/tree/master/recipes/recipeNo023
We are trying to make software for a car parking system using image processing. We used OCR. We intend to use a webcam to obtain images of the license plate when the vehicle leaves and enters. We will then use the number to calculate the time spent inside the park and price tickets based on that.
This is my code:
import java.io.File;
import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract1;
import net.sourceforge.tess4j.TesseractException;
public class TestOCR {
public static void main(String[] args) {
File imageFile = new File("C:"+File.separator+"projects"+File.separator+"plate.tif");
//ITesseract instance = new Tesseract(); // JNA Interface Mapping
ITesseract instance = new Tesseract1(); // JNA Direct Mapping
try {
//String result = instance.doOCR(imageFile);
//stem.out.println(result);
} catch (Exception e) {
System.err.println(e.getMessage());
}
}
}
When I run this, I get this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'libtesseract302': The specified module could not be found.
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:145)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:188)
at com.sun.jna.Library$Handler.<init>(Library.java:123)
at com.sun.jna.Native.loadLibrary(Native.java:255)
at com.sun.jna.Native.loadLibrary(Native.java:241)
at net.sourceforge.tess4j.TessAPI.<clinit>(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at com.nadeem.app.ocr.TesseractExample.main(TesseractExample.java:16)
Initially we had a NoSuchFieldError and after using Maven to fix that we encountered this problem.
Basically this error would come either of below reasons
dll path are not specified properly. You can add in vm argument as below. -Djna.library.path=<folder_contains_dll>, This folder should have three dll files gsdll64.dll,liblept168.dll and libtesseract302.dll
You should have Visual C++ Redistributable for VS2012 installed. Windows 10 doesn't have this installed by default.
You may do below steps to start with
Install Visual C++ Redistributable for VS2012 if its not installed
Clone the project from https://github.com/mnadeem/ocr-tess4j-example
Import the maven project in eclipse
Run the Java class TesseractExample.java
We have a huge Java project and decided to port a part of it to .NET (GUI, etc.). To speed up process we're using IKVM (JVM for .NET). In most cases it works fine but when I reach to Jython code then it got stuck and then throws the exception java.lang.NoSuchMethodException and after PyException. It occures within method PythonInterpreter.interpreter.exec.
Even for simple example:
Java:
class Main {
public static String printIt() {
PythonInterpreter pi = new PythonInterpreter();;
pi.set("integer", new PyInteger(122));
pi.exec("result = integer * integer");
pi.exec("print('hello!')");
return "hello";
}
}
C#:
var code = Main.printIt();
What restriction or limitation causes the exceptions? In general where to find all limitation of IKVM (already searched a lot, nothing relating to this case found). Thanks.
UPDATE:
Using IKVM 8.1 and jython-standalone-2.5.3, JDK 1.8, .NET 4.5
Here is a stacktrace:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "src_python\Util.py", line 2, in <module>
from com.trueship.jyinterface import PyUtil
File "src_python\Util.py", line 2, in <module>
from com.trueship.jyinterface import PyUtil
java.lang.NoClassDefFoundError: junit.framework.TestCase
at Java_java_lang_ClassLoader.defineClass1(Unknown Source)
at IKVM.Internal.AssemblyClassLoader.DefineDynamic(Unknown Source)
at IKVM.Internal.AssemblyClassLoader.LoadDynamic(Unknown Source)
at IKVM.Internal.AssemblyClassLoader.LoadClassImpl(Unknown Source)
...
at org.python.core.Py.runCode(Py.java:1275)
at org.python.core.Py.exec(Py.java:1319)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:207)
at com.trueship.jyinterface.Jyb.findClass(Jyb.java:113)
at com.trueship.jyinterface.Jyb.initUtil(Jyb.java:90)
at com.trueship.jyinterface.Jyb.<init>(Jyb.java:77)
at com.trueship.jyinterface.Jyb.getInstance(Jyb.java:102)
at com.trueship.cordage.orders.JSONOrderParser.parseOrder(JSONOrderParser.java:41)
at com.trueship.cordage.readycloud.ReadyCloudApiClient.getOrders(ReadyCloudApiClient.java:302)
at com.trueship.cordage.readycloud.ReadyCloudApiClient.downloadOrders(ReadyCloudApiClient.java:264)
at cli.ReadyShipper.Windows.MainWindow.DownloadOrders(MainWindow.xaml.cs:75)
at cli.ReadyShipper.Windows.MainWindow.<.ctor>b__1(MainWindow.xaml.cs:49)
at cli.System.Windows.RoutedEventHandlerInfo.InvokeHandler(Unknown Source)
at cli.System.Windows.EventRoute.InvokeHandlersImpl(Unknown Source)
I want to handle mouse event in Linux terminal via java programming. I wrote two program via c++ and java that they do same process.
when i use c++ programming to open and read file ("/dev/input/event3"-mouse event file), there is no problem while running executable file.
(Ubuntu 14.04 terminal and Ubuntu server 14.04 ---> no problem).
But when i used java programming to open and read the same file ,there is a problem while running executable result file "java -jar program.jar" in Ubuntu 14.04 "terminal". No error for opening file , but reading file make an error like this:
java.io.IOException: Invalid argument
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(Unknown Source)
at eventfileopen.m.main(m.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
But when i run the same jar file on Ubuntu server 14.04, there is no error and the program work perfectly.
How can I resolve the problem?(Problem = run the java program on Ubuntu 14.04 with no error.) I guess the problem is related to Ubuntu GUI and JDK,but no idea for resolving that.
My java program code:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
public class m {
public static void main(String[] args) {
File f = new File("/dev/input/event3");
FileInputStream is = null;
try {
is = new FileInputStream(f);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
byte[] bytes = new byte[16];
while(true){
try
{
is.read(bytes);
} catch (IOException e)
{
e.printStackTrace(); //-------> error while run on Ubuntu 14.04 and no error on Ubuntu server
}
System.out.println(Arrays.toString(bytes));
}
}
}
Check that your buffer size is correct.
In recent Linux kernels size of input_event structure is dependent on many things, but mainly on cpu architecture. Here's its declaration:
struct input_event {
struct timeval time;
__u16 type;
__u16 code;
__s32 value;
};
On 32-bit systems it's very likely that your buffer size is accepted(16 bytes).
On 64-bit systems it's very likely that the buffer should be no less than 24 bytes. The reason is that timeval struct takes twice as much space(8 bytes more) than on 32-bit systems.
I haven't found a reliable way to get input_event struct size from Java and personally I use JNI for that.
I'm using Proclipsing (processing in Eclipse) but am getting an error when I try and open a port (printing the serial list works fine). I have a feeling some sort of native library is not connected but I'm baffled as to how to do so in Eclipse (and where it link to).
Here's my code:
import processing.core.PApplet;
import processing.serial.Serial;
public class visualization extends PApplet {
public Serial usb = null;
public void setup() {
println(Serial.list());
println(Serial.list()[5]);
usb = new Serial(this, Serial.list()[5], 115200);
}
public void draw() {
}
}
and the error it throws is:
Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: jssc.SerialNativeInterface.openPort(Ljava/lang/String;Z)J
at jssc.SerialNativeInterface.openPort(Native Method)
at jssc.SerialPort.openPort(SerialPort.java:158)
at processing.serial.Serial.<init>(Unknown Source)
at processing.serial.Serial.<init>(Unknown Source)
at bioauthvisualization3.BioauthVisualization3.setup(BioauthVisualization3.java:15)
at processing.core.PApplet.handleDraw(PApplet.java:2361)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240)
at processing.core.PApplet.run(PApplet.java:2256)
at java.lang.Thread.run(Thread.java:745)
I ran into the same issue while setting up IntelliJ IDEA for development with Processing. But I imagine you can apply the same method in Proclipsing. The solution that worked for me was threefold.
I created a global library that contained the Processing and Serial libraries. In OS X the required jar files can be found in the directory /Applications/Processing.app/Contents/Java/ and /Applications/Processing.app/Contents/Java/modes/libraries/serial/library/. I added the following libraries: core.jar, serial.jarand jssc.jar.
Next I had to add the global library to my module dependencies.
The last step was to add the path to the native libraries to the VM options for the appletviewer: -Djava.library.path="/Applications/Processing.app/Contents/Java/modes/java/libraries/serial/library/macosx"
My guess is that Proclipsing does the first two steps for you but you have to add the native libraries to the vm options manually since these depend on the system you're working on. Hope that helps.
I derived the solution for step 3 from this forum entry.