manifest.mf is overwritten by eclipse during jar export - eclipse

I would like make an executable jar archive with eclipse.
So into my project I created file src/META-INF/MANIFEST.MF :
Manifest-Version: 1.0
Main-Class: MainClass
Class-Path: .
But when I export my java eclipse project eclipse warn me with following message:
"JAR export finished with warnings. See details for additional information.
myproject/src/META-INF/MANIFEST.MF was replaced by the generated MANIFEST.MF and is no longer in the JAR."
Anyone know how I can avoid this when I export my project in eclipse?

While exporting the jar, select the option to use existing manifest and browse to the manifest file of your project. The generated jar will have that manifest file now.
Using existing manifest http://img46.imageshack.us/img46/6752/export.png

Using Oxygen (Release 4.7.0), I was able to do this successfully. The confusing part is that on the JAR File Specification page of the JAR Export wizard, both the Next and Finish buttons are active. So if you don't notice that and just click Finish, you'll end up with a warning (and the generated manifest). To use your own, click Next instead (once for JAR Packaging Options, and again for JAR Manifest Specification).

Related

Eclipse runnable jar export misses some folders

How I did the export:
select the project
right click > export...
Runnable JAR file
The problem:
The jar somehow misses folders in the project that is not under the src/.
I tried exporting as a regular Jar, in which I can select what files to be included. But after some searching, it seems there is no way to auto include dependencies not directly in the project (I'm using Maven and another external lib added by an eclipse plugin).
The "runnable jar" export apparently uses a launch profile to create the jar. I tried to tinker with the launch profile, but was unable to a setting to specify needed files/folders in the project for run.
I found a few articles about using Maven directly, with pom's maven-assembly-plugin to pack the jar without Eclipse. I did a quick digging, and it seems that's a bit raw. If it could be done directly in eclipse, that'd be great.

Eclipse export runnable jar configuration

I am using the eclipse option to export a runnable jar from a project that I am editing. ( I have created some additional functionality through a plugin).
The runnable jar file works fine, except that is does not load the plugin I have created.
So ,I assume that I have to inform somehow eclipse to include the files I have created.
In other words,(forgive if I am asking something simple or obvious) how eclipse knows about the dependencies and all that staff ?
Since the project contained already an ant file for building and compiling ,I am wondering if this is what I have to tune.
Eclipse does not use the build.xml file to export jars. The dependencies information is kept in the .project file.
You can add your plugin as follows:
Right-click your project and select properties, then go to "Java Build Path" and select the "Libraries" tab. Add your jar here to get eclipse to recognize it as part of the project. Next go to the "Order and Export" tab. Select your jar-file here so it gets exported with the runnable jar.
When you build the jar file, make sure to select "Package required libraries into generated JAR" rather than "Extract required libraries into generated JAR". Unfortunately, I can't guarantee this will work. It sounds like rapidminer loads plugins by searching the libs directory. I don't know if it will be smart enough to recognize when it's running from a jar file and look inside the jar file it's running from rather than in the working directory.
If not, you'll have to ask your question to someone who knows about rapidminer.

How to deploy a JAR file with all required JAR files in Eclipse

Can someone please explain how do i compile an app to a JAR file that will include several other libraries?
I have included three JAR files that need to compile with application.
I have tried to go with "Export/Runable JAR File Export" as suggested, but the "Launch Configuration" dropdown is blank.
I tried Running the program and it runs fine, also if I check the "Run Configurations" all seem fine.
What am i missing?
I have downloade MAVEN plugin, converted the project to MAVEN project.
Then i included the POM.XML where i included all the dependencies and JAR signature.
The project is then exported as JAR file with MAVEN install command.

add jar to eclipse plugin (hadoop)

I need to run an Eclipse (Indigo version) plugin, but from the error log I find out that I am missing 2 jars.
How can I add the missing jar to Eclipse so that I can run the plugin?
Is there a way to add the jar to the existing plugin?
If this is of any help, I try to run Hadoop Map/Reduce perspective and I found out that I should add commons-configuration and commons-lang.
The simplest way is to just copy the Jar file(s) into your plugin project, and then go to the plugin manifest (open the MANIFEST.MF file) and add them to the classpath on the Runtime Tab. Also on the Build tab, make sure they are checked so that they are included in the output of the plugin.
There are other ways, like making a special plugin to house only the required Jar files, or get the bundle (plugin) that might already contain that Jar file from someplace like Orbit.

how to exclude external jar while creating executable jar in eclipse or commandline?

I have written a program in Eclipse IDE which uses BouncyProvider class of BouncyCastle.jar. So to compile my class I added BouncyCastle.jar in my project classpath and it compiles perfectly.
Now I want to export my project as Runnable JAR so when I do that from Eclipse, it by default adds the classes of BouncyCastle.jar also in that runnable jar.
But I want to keep my application jar and BouncyCastle.jar different from each other.
How can I achieve this? Can anybody please help?
It sounds like you want to use the "Export JAR File" wizard instead of the "Export Runnable JAR File" wizard. When exporting a runnable jar file, Eclipse attempts to pack everything needed to run the application into a single archive. On the other hand, the "Export JAR File" wizard gives you more control over what is packaged in the archive. You can still create a runnable jar file, but you must make sure to include BouncyCastle.jar on the classpath when you execute the jar. Here are step-by-step instructions:
Click "File | Export". The Export
dialog pops up.
Expand the "Java" folder and select
"JAR file" (not "Runnable JAR
file"). Click Next. On the JAR file
specification page, choose the
classes you want included in the jar
file, and specify the name of the
JAR file to create. Click Next.
On the JAR Packaging Options page,
select options appropriate for you.
The defaults are probably fine.
Click Next.
On the JAR Manifest Specification,
make sure to select the "Main class" for your jar file. This is
the class that will be executed when
you execute the jar file. If you
leave this blank, the jar file will
not be runnable. Click Finish to
create the jar file.
You should be able to execute the jar file by executing "java -jar myjarfile.jar -classpath BouncyCastle.jar" from a command line.
Unfortunately, looks like you can't actually do that. A JAR can't use another JAR that's stored inside itself.
I'd say, unless you have a really strong reason why you can't unpack your BouncyCastle.jar
(like maybe licensing problems?)
just let it unpack (which you can do by adding BouncyCastle.jar as an external archive in Eclipse:)
Right-click on your project
Build Path...
Add External Archives...
Add your archive
Export as runnable JAR)
and watch your package names for conflicts.
Here's an open Java bug ID I found describing your situation
One-JAR may help - a open source solution to your situation
It looks like this has been added in Eclipse 3.5 Milestone 5. See the News for the latest build and bug 219530