The last days I searched how to use Controllers like DS4 in java and it got me to jinput. After downloading the zip file. I added the two JARs to the project and tryed to run a test code, that I found in an installtion guide.
The problem is that it says
no jinput-dx8_64 in java.library.path".
I know there is another Thread for this problem, but I didn't understand it, maybe because of my bad English, maybe because of my knowledge. I tried to fix it by adding the directory of the files to the jre native library in eclipse, but it keeps saying the same errors.
This is only one of the many possible way of including external library
Frist you have to download the library jar
Download from maven
Then you download the natives library for the desired os
Download from maven
Finally you link both the library (jar) and the natives (dll for windows) in the project
Related
How can I compile terminal programs which uses external libraries? I'm using JColor (https://github.com/dialex/JColor) to color my font but I don't know how to compile it.
My IDE is IntelliJ. I already tried to compile my program into a jar but executing it in terminal ignores JColor. No error but no color and cryptic symbols instead. I don't know if it's cause of JColor or I missed something during compiling.
Thank you very much in advance.
Edit : The real issue
(See replies)
We found the issue not to be related to imports, but rather that ANSI control support is disabled within windows terminals by default, but enabled within IntelliJ.
This made it seem as though the library was not working after being exported, or wasn't being exported.
Relavent Discussion
The dependancy
InteliJ gives the option to export libraries with the module from within the Project Structure window:
Assuming the library is configured within your project, all you have to do is navigate to Project Structure > Modules > myModule > Dependencieswhere you can add the library, and tick export
The artifact
Next, create an artifact from your module, with depenencies
The output layout shows the internal layout of the jar after export, check the library is in there.
Now when you build your artifact, it should contain the dependency.
javac -cp /path/to/jar/file Design.java
java -cp .:/path/to/jar/file Design
So, lets suppose your current working directory in terminal is rc/structure/
I've made a project in Java using Eclipse using the jnetpcap library which needs WinPCap to be installed to work properly. However, there's no winpcap library included in my project only jnetpcap. But when i extract the project into a generated jar with libraries, or with the libraries in a different folder, it somehow doesn't work. Why does everything work when i run the program from eclipse, but not as an extracted project?
Thanks in advance.
I faced the same issue few years back. Jnetpcap for eclipse comes with winpcap. You need to export your project on eclipse as runnable jar. There you have an option to select which says extract required libraries in the generated jar. In this way, the all the dependent libraries will be included in the exported runnable jar file.
The links below are some of the helpful links:
Create runnable jar in eclipse
Visit the post on winpcap website jnetpcap: a java wrapper for libpcap and winpcap
Does this thread helps you out? I would guess that you have not wrapped your dependency into the .jar file but only in eclipse. That is why it works inside your IDE.
You didn't declare your main class for the jar file.
Right click on your solution in eclipse->Run as-> Run configuration -> Main class -> choose you main class.
Now build your jar from the beginning and try to execute it.
I'm facing a problem I have never had before when exporting my eclipse project with external library. I made a little program with spelling correction and I used the language tool library you can find here.
I put this library in the build path and correctly imported into my eclipse project. When I ask to export it into a runnable jar, Eclipse exports only the jar files into languageTool library, but this library contains also some txt and xml files. So when I try to launch the application from command line it gives me error because can't find this txt and xml files. I tried to add to my jar archive manually but obviously it doesn't work. How can I fix it?
Thanks for your time and forgive me for my bad english.
I'm currently working on a project where I'm using the LWJGL library and I just tried building a .jar out of it all, now the problem is that nothing happens when I try to start the .jar.
My only thought is that maybe the library didn't export correctly but I've been looking around at the other questions here for a while and I've have added everything correctly at the Dependencies tab in the Project Structure, the libraries I need are also in the Artifact Output Layout as extracted directories.
I just tried checking the stacktrace with cmd and it says that it can't find lwjgl in the library path so I'm guessing there's something I don't know about .jar files or something that's causing this error.
Here's the stacktrace:
Also in IntelliJ I've put "-Djava.library.path=lib\native" in VM options, is it possible that this doesn't apply to the .jar or something.
Help is appreciated!
There is a rather complicated process to make an executable jar with LWJGL. You need to use Jarsplice.
Jarsplice has 4 steps which are pretty self explanatory but here they are anyway:
1: Add Jars.
Add the jar you generated as well as all the libraries. That includes lwjgl.jar, and any other jars you used.
2: Add Natives.
Add all the natives you used in your project. These are the files you referenced using -Djava.library.path.
3: Main Class
Select the main class of your program. This could be something like com.example.game.EntryPoint.
4: Create Fat Jar
Click "Create Fat Jar" to create your executable jar!
You can also optionally create a Windows .exe, OSX .app, and Linux .sh executables as well.
I'm trying to download jsoup on my mac (Mountain Lion). I've downloaded the jsoup.jar file and installed the last java 7 from the site. But here is the problem, when I double click the .jar file it tells to me:
The Java JAR file “jsoup-1.7.2.jar” could not be launched. Check the
console.
I can't find even the console! Someone can help me? I read a lot of answers about this topic, but they all talk about Java 6 and it has different settings that can't find.
EDIT
i also tried from the terminal with this command:
java -jar /Users/Ben/Downloads/jsoup-1.7.2.jar
but it tells me:
Failed to load Main-Class manifest attribute from
/Users/Ben/Downloads/jsoup-1.7.2.jar
The JSoup JAR is not executable, so you are not going to be able to 'run' it in any of the ways you described. You are supposed to include it in your project classpath and use classes from it to do your parsing (after importing them of course).
You might want to refer to the JSoup Guide for examples on using the library.
I guess you are trying to run the jsoup library as a standalone application assuming it to be an executable jar. All indicates that the jar file you are using is NOT an executable jar hence it wont work.
jsoup.jar is supposed to be used as a java library and you will need to write java code to be able to use the HTML parsing capabilities.
If you are using an IDE like IntelliJ, you can open the module settings for a particular project and select Libraries. There'll be an option to add a particular external library from the Maven repository after which you can download the JAR and include it in your project's dependencies.