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.
Related
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
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 have this, perhaps, easy problem, but I don't know how to handle this.
I have my Java program and it works pretty well when I call it via terminal (Java command).
The program uses 4 text files from the hard disk which can't be added as resources to the project.
How to do this right so I could build jar file only with main class and files from hard disk (first one is a config file and it has paths to other files so the program knows where they are)?
I'm using IntelliJ IDEA 14.1.4 on Arch Linux.
I did it based on this blog, but it's not working without txt files in src folder.
Also "jar cvf" command builds jar file, but it's not working outside my computer (for example on windows or OSX).
Can anyone help me?
I prefer step by step instruction so I would understand what is going on in here.
I recommend to build your application with Maven and create a Maven Assembly which contains your JAR file as well as the config.txt file.
I have a Swing desktop application and have created a jar file which depends on library (which is kept in ./lib/) and a .txt file in the same folder. Now to execute the jar I have written a .bat file which checks if Java is installed or not. If installed then I run the jar file with command:
javaw -jar TagEdit.jar
Now there are two problems I am facing with this:
I would rather prefer a single executable, if possible.
As using bat file, the console is visible in back (looks kind of weird). Is it possible to turn it off?
Java is everywhere, and there are lots of applications that are built in Java and packaged in a setup, or given as exe. I Googled a lot but could not find a way to create a setup for the software or an exe. How are those software packaged?
Have tried jlaunch, but could not get that to work correctly.
Himz, Eclipse can automatically build a so-called "fat-jar" for you. It is a jar that contains all the dependencies you need.
If you are a happy Maven user, then you have two brilliant alternatives - the shade plugin, and the assembly plugin. They both can produce a "fat-jar" for you. :)
There are various answers to this.
javaws.exe will execute the jar without the console appearing behind
But I feel this isn't really the best way.
I think should investigate using Java Web Start, So you create a JNLP file and have it jar downloaded from the web, I think, you can also have a desktop icon.
If you don't want that
I think you can get/buy binary wrappers for the jar.
You could convert it to an executable. Try Googling java to exe.
Once that is done, you could package it up as an installer using NSIS.
How would you go about getting sshj installed, considering that I'm using Eclipse on ubuntu? I haven't done anything with Java in 2 years and the only thing I sort of remember is how to add a jar file to a project, but in the case of sshj, I only have .java files.
The jar is present in the zip distribution available on the downloads page for sshj.