Useing Ant to build a Jar file WITH COMMENT - eclipse

I have a Jar build from my own project(using ANT),
my project have comments in java files,but when i use this Jar in new project,I can't see the comments(by press F2 in eclipse),Some one said that I can't see comment unless i have the source file of the Jar.
The question is,is that true?or there's some other way to have comments with my Jar(without Source files)?

The comments from your source code are not part of the compiled class files, so they will not be visible unless you provide the source java files
You can generate javadocs and include them with your jar library. There is a javadoc ant taks to generate the javadoc. You can then either include it in your jar file, or provide it separately. If you include the javadoc inside the distributable jar, whoever is using your jar will have to either extract the javadoc out to view them, or specify that the jar file also contains the javadoc inside the IDE

Related

Creat JAR from .jardesc in eclipse

I have a question with respect to compiling java codes and building a jar file on Eclipse platform. I would like to know if the Create JAR option on eclipse from a .jardesc file will still create a JAR file inspite of errors in the compiled Java codes? If yes, how can i enable this option in my Ant build xml?
If you edit your .jardesc in Eclipse (Open With – JAR Export Wizard), you can modify the behavior regarding errors/warnings on page two of the wizard:
.
This apparently toggles the attributes exportErrors and exportWarnings, respectively, at XPath /jardesc/options in the .jardesc file.
As far as the behavior of a corresponding Ant build file is concerned, you should probably take a look at the failonerror parameter of the Javac Task.

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 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.

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

Eclipse: How can I attach JavaDoc to multiple JAR files?

I am using Eclipse 3.4.1.
I have an external library that consists of a bunch of JAR files, and some HTML JavaDoc. I know that I can attach the HTML JavaDoc to individual JARs by going to their Properties page, JavaDoc location, and setting it there.
But it would be a pain to do this for each individual JAR. Is it possible to do them all at once somehow? The JavaDoc location is the same for them all.
Not really a recommended solution, but you could set it for one of them and then manually edit your project's .classpath file, copy the relevant part and paste it into the other elements. Not that much easier than setting it for each one separately, though.
Also, if you have access to the source files, you could use these instead of the Jar files, which will provide the Javadocs.
I had a related question, on how to efficiently attach JavaDocs for dozens of JAR files from our in-house projects which are in a Maven repository. The solution was to use the Maven JavaDoc Plugin to automatically build and install JavaDoc and Source artifacts for each project. Then in Eclipse I could import all of these resources with one step by right clicking on the project->Maven->Download JavaDoc. Then Shift-F2 does its magic.
That process only works for dependencies which are not in my Eclipse workspace. For each of my Eclipse projects, I still had to configure its JavaDoc location manually, but at least there are fewer of these.
Here's a related topic:
How to reference javadocs to dependencies in Maven's eclipse plugin when javadoc not attached to dependency