How do I get the opennlp api files recognized to compile? - java

I've downloaded the OpenNLP tools, and was able to get the command line tools to run after adding the right paths to my bash file, but I can't figure out how to get the api files to work with my IDE (Netbeans).
For the command line tools I'm pointing the path to the /bin directory. There are four jar files in the /lib directory: jwnl-1.3.3.jar, opennlp-maxent-3.0.3.jar, opennlp-tools-1.5.3.jar, opennlp-uima-1.5.3.jar.
Any help on where to put these files, and how to access the opennlp tools api in Netbeans would be greatly appreciated.

To use the API (either training or tagging), you only need opennlp-tools-1.5.3.jar. In NetBeans, if you have external library dependencies, see this question:
How to add a JAR in NetBeans

Related

How to properly make jar archive to run Java program on different systems?

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.

Eclipse export libraries with non jar files

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.

Can't open a .jar file on my mac

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.

convert a java project (I used in it JLayer 1.0.1 to play mp3) to a runnable jar file

I built a java project and I used (JLayer 1.0.1) to play mp3 audio.
when I test my project with eclipce I find that it worked correctly 100% and the JLayer 1.0.1 libraries play my mp3 files efficiently.
but when I convert it into a runnable jar file it works with NO SOUND OR AUDIO.
It seems that my program can't reach for Jlayer 1.0.1 libraries.
So now,I need your help to resolve this problem.
with my thanks
You can do the following in order to test your application: export your project as a regular jar and copy it together with the JLayer.jar and other dependencies to a directory. Then, create a batch file (.bat on Windows, .sh on Linux) that would include something like this:
java -cp yourjar.jar;JLayer.jar;other_jars FullPathToYourClass
where FullPathToYourClass is something like com.something.else.ClassName
Also note the the separator on Linux is :
Once you see it working, you can start to do a build script to do the above automatically. I would suggest you build an Ant build.xml file for this.
This can be a JRE issue (Eclipse can be using a different JRE from what your system uses), or a packaging problem.
When packaging using Eclipse, make sure you package all libs together with your classes. Do to that, select the option "Extract required libraries into generated JAR".
Another option is to run your JAR setting the classpath: java -cp yourjar.jar;yourlib1.jar;yourlib2.jar com.your.package.YourMainClass (note that the ';' is platform dependent) instead of java -jar yourjar.jar.

How to convert jar files into exe & rpm

I have the following jar files for my app:
DesktopApplication1.jar
Plus , i have used the some extra API's for my app , like jsoup, jexcelapi etc. There are about 7 api's in the lib folder.
How to make a EXE file & RPM file out of all these jar files?
P.S. I am a first timer. So take that into consideration.also, I have used Netbeans 6.8. So the main API is in \dist folder. And the API used is in \dist\lib folder.
thanks in Advance
use jsmooth to make exe from jar
Build your JAR with fatJar to include all the dependencies in it, and then make it executable with your favorite tool (I use Launch4j)
RPM is little bit different, since it is not executable, but package format. There are lots of tutorials, how you build it up.
You could make a BAT file a file with .bat(For windows) extension
Just open notepad and write the following text
java -jar DesktopApplication1.jar
Save the file as filename.bat(the .bat extension is important)
Place the .jar and .bat files together and just double click the .bat file every time you need to run the jar...
If you don't want to keep both together then give the absolute path of the jar in the .bat file
java -jar AbsolutePath/DesktopApplication1.jar
For a linux machine make a file with (.sh) extension rest of the procedure is same...
Try InstallJammer. It provides what you want.
Deploy the app. with Java Web Start. JWS Can make it easy to add other Jars to the apps. run-time class-path, avoiding the common problem with fat jar of violating the API's distribution license (when it says WTE 'you are allowed to distribute this in unaltered form..') and can provide the further benefit of only downloading the parts that the user requires (when the user requires them).
JWS has many other cool features like desktop integration (menu bars, start menu item), splash screens, automatic updates, support by the owners of Java, and compatibility with any platform for which Java is available.
For creating .exe to run on Windows:
Download launch4j from http://launch4j.sourceforge.net.
build wrapper .exe through launch4j.
Download innoSetup from http://www.jrsoftware.org/isdl.php.
Build .exe as installer, the setup file, for user to download and install.
Install rpm for linux:
If your application used other native libraries, you need to download and install Linux native libraries. This is how we build rpm for our app.

Categories

Resources