How can I use netbeans to export each package into separate jars? - netbeans

Right now, netbeans exports all the packages in a single project into a single jar, I would like it to export a separate jar for each package, how would I go about doing that?
Would also like to know how can I include all my dependent libraries into the generated jar

Related

Keep external JARs outside the project JAR while creating product in Eclipse

My eclipse project structure is as given below
->MyProject
-->JRE System Lib
-->plugin dependencies
-->src
-->extJars (contains some external JARs)
-->icons(contains icons files)
-->META-INF
-->build.properties
-->plugin.xml
-->Myproject.product
When I export MyProject as a product using Eclipse MyProject.product, complete files in MyProject including ExtJars and icons get bundled as a single JAR file.
MyProject/plugins/MyProject_1.0.0.0.jar
I want extJars and icons to be kept outside that single JAR file.
Kindly help me in achieving this.
Thank You
If you use 'features' to build your product you can use the 'unpack the plug-in archive after the installation' option in the 'feature.xml' to have the plug-in expanded when it is installed.

get Eclipse to export libraries as a jar

How can I get Eclipse to export as a non-runnable jar all the contents of JRE System Library [JavaSE-1.6] and Referenced Libraries?
I want to use -classpath to bring together several jar files rather than use Eclipse's Export > Runnable JAR file. Motivation: swapping out a single class that happens to be in a package of its own, by swapping the jar.
It's easy enough to export my own packages in (non-runnable) jars but now I need the "library" classes as well and I have not found an easy and obvious way to do that.
There is an option when you export a runnable JAR to "Copy required libraries into a sub-folder next to the generated JAR". Would that work for your case?

How to create a GWT Library jar from existing GWT Project?

I have a working GWT project library which I include to other GWT projects that need to use it. So far its been useful enough, however I need to make it a library jar, what is the process of doing it?
I tried to export the jar using File->Export->JAR File process with Eclipse however when I included the jar file in the same projects where I used to include the project file, it won't work.
Any ideas?
Make sure you package *.java along with *.class. Module gwt.xml should also be placed in correct package.
See an example here.
In eclipse export wizard, make sure "Export Java Source files and resources" checkbox is checked.

Eclipse: Package multiple projects into one JAR

I have multiple projects but only one with a Main class. The one with the Main class depends on the other projects. These projects are referenced in Eclipse, but when I export my JAR, the other projects are not exported with that JAR.
How can I export my Main project and "include" the other projects into that same JAR? I'd rather not have several JARs and have to define them into my Classpath on the command line.
Don't do it the hard way. Use Eclipse's own exporter. First ensure that you've the other projects referenced as Projects in the main project's Build Path. Once done that, just rightclick the main project, choose Export and then Java > Runnable JAR file. Choose the launch configuration (which you used to test the main() class locally) and then you've 3 Library Handling options to package the JAR:
The first option will just repackage the classes of other projects inside the JAR. Everything is plain thrown together.
The second option will copy other projects as JARs inside the JAR. This does normally not work that way, but Eclipse also adds a special launcher which basically copies the embedded JARs into memory, extracts there, adds the files to the classloader and then invoke the main() with that classloader.
The third option is something you don't want for this particular case.
If I were doing it I'd 'mavenize' the projects, using a maven dependency for each project dependency and then use
mvn assembly:assembly
see http://maven.apache.org/plugins/maven-assembly-plugin/ for more on this plugin

How to export GWT project classes into JAR file

I find it difficult to export classes from one project into JAR file, so that I could import it in another project.
How do I try?
I right-click on project in Package Explorer -> Export -> Java -> JAR file -> select all the packages I need. 'Export generated class files and resources' option is checked, other options are left unchecked. Then I click Finish.
When I import such generated .jar file into the dependent I encounter a list of errors:
The import pl.abc.xyz cannot be resolved
Xyz cannot be resolved to a type
It seems like the classes from the JAR file were not found by the compiler.
Please correct me, if I do it in a wrong way. Thanks.
It seems that you need to include in jar also java source files from the client package (sometimes also shared package depending on your GWT module structure as defined in *.gwt.xml file).
The GWT compiler requires java source for the part which has to be compiled into Java Script, to be availabe as classpath resources along with compiled classes. It is simple to achieve with ant or maven build.
You can also check Export Java source files and resources when exporting, but it will add all the source code, not only the client part.
Make sure you inherit the module in your .gwt.xml file. You want to inherit the .gwt.xml file from the GWT jar you are importing, for example:
<inherits name="com.example.youmodule.Name" />