binding class files in the jar file not generated by netbeans - java

When i clean and build my project using netbeans , though it makes the jar file of the project but it doesn't keep those files that i myself kept in the project folder. That includes some class files,a music file. What is the reason for this ? How do i do this ? I want to keep some class files not generated by the netbeans and also the music file.

What is the reason for this ? default Netbeans build.xml don't include other lib files.
If you look the dist folder you can see a lib folder too. This is your lib folder. If your lib files is in the classpath you jar run on every where if not your file look ./lib/*.jar
You can change your project to ant project or maven project and change your manifest and other files.

Related

Is there an option for intellij to build directories outside the JAR file?

So what im trying to do is to build a JAR artifact which should include the necessary libraries as well as directories which are outside of the JAR file and can be looked at in the explorer.
I have already tried to add directories to the artifacts but these get put into the JAR file in a folder which i cant access later when converting it to a exe using launch4j.
Is there an option in Intellij to exclude directories from building into a JAR?
Edit: I want the output directory like this
Directory Structure

How to use Jar file As a Java project in Eclipse

I have a jar file of an existing project. I want to write Junit test cases for each class in that project. To do that, I want to import that jar file as a java project in Eclipse so I can start new development of the same code. Is it possible to import a .jar file the same way we did for a .war file, and start developing the web project? If so, how?
A .jar file is just a .zip file containing all the class files of your java project. If the source files are included in the .jar file, you can unzip it and add them in eclipse. If they aren't, then you can't do what you want to do.
If you have source files in your jar i.e .java files along with your .class files, then rename your jar to zip and unzip the files. These java files can now be manually copied under src folder in eclipse.
Once your modifications are done, the new jar with your modifications can be created like this -> Right click on project ->export->Java->Jar option in eclipse. Or you can use ANT/Maven or similar build tool.

JSPF is not loading lib of jar

I am using Java Simple Plugin Framework. I export a jar that has my plugin implementation. The implementation depends on a library, which I have as a jar. That jar gets exported within the lib directory of my jar, and added to the classpath of my jar.
But when I load my jar with JSPF, it fails with "NoClassDefFound" because it can't find the jar in the lib director of my jar.
My apologies if my approach off base; I just need to know how this is supposed to be done. How should I bundle my plugin implementation as a jar if it depends on another jar?
I used JSPF and achieved this requirement the following way:
place the library jar file in a folder called lib outside the plugin jar file. (So that
the lib folder and the plugin jar file is in the same folder). Then I added lib/"name_of_libjar" to the classpath entry in the manifest.mf file of the plugin jar file (Which should be inside the plugin jar files META-INF folder), and it worked fine for me.

adding a jar to reference library

I have a jar file I could attach it to project reference library, but it does not have META-INF folder. Does attaching a jar by configuring build path still works?
If you are talking about Eclipse, yes, a .jar file without a META-INF folder works on the build path of a project. I just tried it.

Deploy Eclipse 4.1 Project

I have create a simple program using Eclipse 4.1.. I wanted to build or deploy my project into a .jar. I also added external libraries in my project. I wanted the output same as in Netbeans with the .jar file and lib folder in the dist folder, but there should be also a folder named help and lang.. How can I do this with eclipse?!
Follow the steps provided here.
Or if you don't want to complex things up, select Runnable JAR file instead of JAR file set the directory where the .jar is to be written then click Finish.
Eclipse will create the [Project Name]_lib directory for the external libraries included in the project.

Categories

Resources