I've found a bunch of Stack Overflow Questions and Answers, but so far I haven't found any that work for me. I am trying to make an executable jar in Eclipse from a program which requires an extra jar and a dll. The way I got this to work properly in Eclipse is by configuring the Build Path as shown in
this image. The hierarchy of the project is this. I've tried messing with the Manifest file a bit, but I haven't made any progress with that.
I've been running the jar by using java -jar /path/to/jar and I keep getting an error saying Exception in thread "main" java.lang.NoClassDefFoundError: com/jacob/activeX/ActiveXComponent .... I've tried defining a path to the jar using -Djava.library.path=/path/to/jar and I get an error saying Error: Could not find or loaded main class outlook_dl_2.jar.
Is there any way to solve this without using a third-party application like One JAR? That's the only thing I can find that I haven't tried and I'm trying to avoid it if possible, since I feel like it really shouldn't be necessary. I'll use it as a worst-case scenario, but I would like to get this working without it.
Anyone know what I'm doing wrong here?
Related
After exporting a game app I'm making as a runnable .jar file, I ran it from the command prompt only to find some issues. I've had to solve some issues with not finding audio path and not being able to read/write into .txt files. Audio I've looked and was able to solve, the files one I looked and came to close to solving it but after making a post here I learned all I was missing was a . at the start of my fileNames. Now there's only one problem left.
When I export it with:
extract required libraries into JAR
it gives me this exception:
Catched FileNotFoundException .... -natives-windows-i586.jar(System couldnt locate especified file) ...
Exception in thread "main" java.lang.UnsatisfiedlinkError: Cant load library: ...\gluegen-rt.dll
When I export it with:
package required libraries into generated JAR`
it says:
Catched MalformedURLException: Could not open Inputstream for URL: 'rsrc:glugen-rt-natives-windows-i586.jar', ....
Exception in thread "main" java.lang.reflect.invocationTargetException
Caused by: java.lang.UnsatisfiedlinkError: Cant load library: ...\gluegen-rt.dll
The build path looks something like this:
Source: CubeSurvivor/src
Projects: JOGL (where glugen-rt.dll is and this project is required because it contains everything related to graphics)
Libraries: JRE System Library[JavaSE-1.8]
Order and Export:
CubeSurvivor/src with box filled
JRE System Library[JavaSE-1.8] box not filled (tried with box selected)
JOGL box not filled (tried with box selected)
I dont understand what I'm doing wrong, from the looks of it, it seems maybe the project containing JOGL isn't going to the .jar file but I've confirmed that it is while opening with 7-zip but I couldn't find gluegen-rt.dll (maybe haven't looked well enough its thousands upon thousands of files). That file along with other .jar files are located inside a folder on JOGL.
Maybe this file isn't being copied or extracted to the .jar file created?
Or is there something wrong with my build path? If so, what should I do?
Should I add all the files inside JOGL to the src?
Edit:
I extracted the jar file with 7-zip to run a file search, I made random searches(after all its thousands of files) and all except those in a folder called lib, JOGL.iml and referenced libraries, all inside JOGL, were not found, the folder itself was not found. Everything else was.
Heres what the inside of JOGL looks like:
JOGL Project View
lib, JOGL.iml and referenced libraries are not in the jar file aparently.
Ok so this thread has been resolved, the answers are in the comments, so if anyone encounters a similar issue be sure to check it. I dont know how to make this thread end, im sure a moderator will see it.
So, i just wanted to say thank you all for your precious help and sorry after all it was my mistake not using JOGL properly. This link might help others in the future so im posting it here.
http://jogamp.org/wiki/index.php/JogAmp_JAR_File_Handling#Eclipse
I exported a Java project of mine from Eclipse to a JAR File, and after searching the internet for an hour, have still not resolved my problem. The jar file works on the computer that I compile, and exported it on, yet when I transfer it to my laptop it states that "A Java Exception has occurred" when I try to double click it, and when I run the code below, it retorts "Error: Could not find or load main class jar"
java -jar C:\Users\Me\Desktop\test.jar
I exported it once more after specifying to the MANIFEST.MF the location of my main class, yet the same error is being reported. I have seen the MANY other threads on this on this forum, yet the advice has either been too vague or just plain didn't work.
Thank you in advance.
Check the version of java you are running in your laptop, the error could present itself if you compiled your program with a different version that the one you are using to run it.
I'm trying to run a piece of sample code to connect to a specific DVR. I've got the SDK from the DVR manufacturer. The code tries to call a native library like this:
DHNetSDKLib INSTANCE = (DHNetSDKLib)Native.loadLibrary("dhnetsdk", DHNetSDKLib.class);
But, no matter where I put the dll file, I always get this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'dhnetsdk': Specified module could not be found.
This being a piece of demo code, I feel this should work. The dll files are placed in the root folder as standard. I've tried copying them to the windows dll folders, gave them a folder of their own (C:\dll), adding this folder to the PATH variable, editing project properties to include the various folders to the build path, pointing to it like this:
DHNetSDKLib INSTANCE = (DHNetSDKLib)Native.loadLibrary("C:\\dll\\dhnetsdk.dll", DHNetSDKLib.class);
But nothing works. I've searched a lot but I have yet to find a solution. Most threads I come across however usually don't have the module bit in the error. Perhaps there is something wrong with the dll?
I'm trying to do this in java because I want to build an Android application using this dll, but now I'm wondering if that is even possible. The only search results I find are related to native Android code (I think). This project is being run as a standard application for testing purposes however.
I'm a little confused by this error. I'm new to Java and the error seems pretty self explanatory, but I've checked my paths (even defined my own) and it still fails to find this library. Is there something I'm doing wrong? See directory screenshot and error screenshot below:
UPDATE
UPDATE 2
If I create a new NetBeans project this works fine. Same code and everything. If I create new IntelliJ project I get this error above. I must be missing something in IntelliJ
UPDATE 3
Found the solution. Adding dependencies is a bit different in IntelliJ. Thanks all for the help.
http://www.jetbrains.com/idea/webhelp/configuring-module-dependencies-and-libraries.html
Obidisc4j is a .jar file. You just dont see its extension in the explorer.
Regular jar files are not loaded by System.loadLibrary. They are automatically loaded by the JVM's classLoader.
You are using a native library. It doen't matter if that library is in the classpath. There are 4 ways you can make the Java runtime load your shared library at runtime:
Call System.load to load the .so from an explicitly specified absolute path.
Copy the shared library to one of the paths already listed in java.library.path
Modify the LD_LIBRARY_PATH environment variable to include the directory where the shared library is located.
Specify the java.library.path on the command line by using the -D option.
Seems like your application is trying to find out a obidisc4j.dll (for Windows) or obidisc4j.so (for Linux). The file must be present on the PATH (but not the classpath). If you are not sure what PATH is your Java application searching in, you can write the following statement, before the point where the exception takes place, to find out the PATH.
System.out.println(System.getProperty("java.library.path"));
This will tell you about the paths where your DLL or SO file should be placed. You just need to place the file in ONE of those N-paths.
I'm doing the Ludum Dare 25, using Java Libgdx trying to export my jar.
It was working absolutely fine earlier, I exported and could run it fine. Now when I export it the exact same way, it crashes as soon as I open it. Running via CMD I get the error
'Could not find or load main class'
I've opened it up in winrar and checked the Main class is there and the manifest points to the correct place. I don't understand what's wrong.
All help appreciated, many thanks!
Solution Found
Odd issue, despite the error message had nothing to do with the class, the jar exporter made one of my image files lowercase or something, so that it was messing up it's references