I have a project that uses a few jar files which happen to be JNI wrappers calling some DLL libs. I included those jars in the classpath and specified the native library location for them from within Eclipse (java build path->Libraries), as suggested by some posts in this forum.
However I still received error like:
C:\projects\java_workspace\lib\\xyz.dll: Can't find dependent libraries
Some interesting facts:
1. If I set %CLASSPATH% for jar files and %PATH% for DLL path as env variables and run the program from command console, it works like a charm;
2. I used Dependency Walker to check the xyz.dll in question, even though I can find the dependent dll files in the expanded tree under xyz.dll, from the list box at the bottom I did notice there were two dll files that Dependency Walker complains "Error opening file, the system cannot find the file specified".
Anyone can help config the Eclipse env so I can run the program from within the IDE? Or any comments?
Thanks!
John
Did you try setting the PATH environment variable in the 'run configuration'? (Right-click on the java file containing your main, then 'run as', then select 'run configuration'.)
Related
As the question states, I can't find the Java build path within the project properties itself
My main issue is that I keep getting "The Class file is not on the classpath" error whenever I try to open a .class file from a school project. To fix this I need to access the Java build path within project properties but it is not showing up for me. I'm not sure how to fix this.
I don't have Mac, but i guess You should try this if you haven't done it yet.
File-Import-Existing_project into the workspace. Browse to the location where the .classpath and .project files locates in your project.
Then check your environment variables (google can help with this) and classpath variables:
Window - Preferences - Java - Build Path - Classpath Variables.
The project seems like is a general project (No java project), so it's normal that 'Java build' option is missed.
Besides, you can't open .class files, because is a Java compiled file by the Java compiler. You must search for .java files.
I have created an application using the JFreeChart library for use on another machine.
Previously I have developed applications with JFreeChart (using the same libraries) which has worked fine on other machines. The only difference is this machine is running Vista.
Please see below for the run-time exception I am getting:
The class that cannot be found, however, is located in the highlighted jar in the below image showing my imported libraries for the JAR. I have also established that this JAR is included in the manifest for the application. See below image:
So I very much need this to work and have no idea where to look next - or what is causing this problem!
Development machine Java version:
1.7.0_45
Target machine Java version:
1.7.0_45
Thanks in advance.
Check the Class-Path attribute in your JAR's manifest, which should contain entries like this:
Class-Path: lib/jfreechart-1.0.17.jar lib/jcommon-1.0.21.jar …
Also, examine dist/README.TXT in your NetBeans project folder, which should say something like this regarding libraries required by your project:
To run the project from the command line, go to the dist folder and
type the following:
java -jar "CISOnlineMonitor.jar"
To distribute this project, zip up the dist folder (including the lib folder)
and distribute the ZIP file.
This has nothing to do with os i belive.You dont have all the necessery libs within your jar.Try to open a jar and see if you have them in.Fact that you are able to run it on your maschine only proves that.Make executable jar with eclipse or whathever you use.And when it ask you for libs check -Extract required libraries into generated Jar.
if you dont know how to get to that point
File>Export>Java>Runnable Jar File> Runnable JAR File Specification.
Also right click on your project and check Your build path.
RightClick project>Properties>Java Build Path>Libraries
Make sure you have everything correct
EDIT-
As i see you use NetBeans im not sure exactly how to find all this there.Bud it will be very similiar.
I am having trouble exporting my java project from eclipse as a jar executable file. My java project uses an external library (its called jri). I have exported the jri.jar file and set the library path for its native library in eclipse, and it works great in development in eclipse. However, when I export it as an executable jar file I get the following error:
Cannot find JRI native library!
Please make sure that the JRI native library is in a directory listed in java.library.path.
I have placed a folder called lib in the same directory as my project's jar; this lib folder contains jri's native library. jri's native library is not in one file but in a folder. This is the same setup I have in eclipse.
The way I am exporting my project in eclipse is
Export...
Java > Runnable JAR file
Copy required libraries into a sub folder next to the generated Jar
Finish
And my folder is organized like this
folder project
project.jar
project_lib
jri.jar
jri native library folder
The MANIFEST.MF of my project.jar is:
Manifest-Version: 1.0
Class-Path: . project_lib/jri.jar
Main-Class: index
What I want to achieve is to give another person a folder including project.jar and anything else needed so she/he can run it without needing to install anything else.
Thanks so much
Add a script containing something like that:
#!/bin/bash
java -Djava.library.path=project_lib/native/ -jar project_lib/jri.jar
I export some java projects that way.
This is relatively hard to implement. The solutions I have seen involve extracting the native libraries in the JAR to an OS temp directory and then loading it. I would go for an integrated solution for that. One Jar and Java Class Loader support it, and on the second page you will find links to similar tools.
You can put the libraries inside your jar:
Export...
Java > Runnable JAR file
Package required libraries into generated Jar
Finish
I always export this way.
I don't know if it will work in your case, but worth a try.
Edit:
See these links:
Instalation, setup and setting environment properly
What to do when getting Cannot find JRI native library!
My guess is that this have something to do with LD_LIBRARY_PATH not correctly been set. Or the file wich it is searching for isn't in the path listed.
You know I had the similar problems
Could not extract native JNI library.
all above proposes can't help me. I couldn't stop and start gradle deamon by using follow command:
gradle --stop
I saw that gradle deamon still not stopped in my processes. That's why I kill it in my process and all will be fine :)
I want to try out the Java3D library and have used the installer to auto-install them for me (I'm running windows). I was using Elipse and noticed that it couldn't find the packages. I tried compiling a class outside of Eclipse from the command line and has the same issues there.
The installer has definitely put the jar files in my java-sdk/jre/lib/ext folder so I'm not sure why it isn't automatically detecting them as I thought that this folder was automatically searched.
I then manually added the jar to the classpath by setting the CLASSPATH environment variable and the program outside of Eclipse then worked. Eclipse still couldn't find them, so I added the jars to my Eclipse project and it works.
The thing I'd really like to know is why I had to set the CLASSPATH environment variable when the jars were installed in the jre/lib/ext folder.
Other information is that I notice that there's no JAVA_HOME variable in my environment variables. Should there be? This might be the problem.
Also, just for interest (and learning) I notice in the Java installation that there is a JRE folder inside the Java-SDK-1.6.xxx folder and also another one in the same directory as the Java-SDK-1.6.xxx folder. Why is this?
Many thank in advance.
Joe
Check this .
http://www.ntu.edu.sg/home/ehchua/programming/howto/Environment_Variables.html
Without JAVA_HOME environment variable java Extensions classloader is unable to find path to jre/lib/ext dir. Because, by default, the extensions class loader loads the code in the <JAVA_HOME>/lib/ext.
See Java Classloader for more details.
I'm trying to include a weka-src.jar file in Netbeans project and use it.
I already have set up my CLASSPATH and included :
C:\Program Files\Java\jre6\lib\ext\weka-src.jar into it
My JAVA_HOME variable is set to:
C:\Program Files\Java\jdk1.6.0_25\bin
but still I get the error in Netbeans: package doesn't exist and NetBeans doesn't auto-complete when I'm trying to add it to imports
Similar to this I jave a jar file
C:\Program Files\Java\jre6\lib\ext\mysql-connector-java-5.0.8-bin.jar
also included in CLASSPATH and after adding to project Netbeans does the auto-complete thing.
My cmd:
echo %CLASSPATH%:
.;C:\Program Files\Java\jre6\lib\ext\mysql-connector-java-5.0.8-bin.jar;C:\Program Files\Java\jre6\lib\ext\weka-src.jar
Tried in Eclipse, the import part is not underlined, but still I can't use the classes, as if weka-src.jar wasn't even added
I can't figure out what is wrong. Any hints, please?
Maybe there is someone who can test it in his environment? weka-src.jar is in Weka's program files folder.
I am guessing that weka-src.jar contains source code which need to be compiled before it can be used. Perhaps there is a weka.jar which has the compiled classes in it.
In netbeans, you don't make classpath with windows environments variables, but with netbeans.
In netbeans right clic on your project node in window projects, choose Properties, and in properties Librairies. Add your jar.project/librairies with that.
Istao is correct. For NB you need to add jars via Properties