I have a little problem importing a project to my android project.
I have built a little library using Ical4Java to parse a .ical file, and that library is exported to a .jar.
In my Android Project i have imported and added to the build path my generated .jar from my library that includes some jars to make my library work.
But when i run my application it just crashes and i get this on the LogCat:
E/AndroidRuntime(14382): java.lang.NoClassDefFoundError: net.fortuna.ical4j.data.CalendarBuilder
That library (ical4j.jar) is imported on the library buildpath and is exported whith my library (mylibrary.jar)..
You can use One-Jar to help you use a jar file that is dependent on other jar files. Basically you can combine them into one jar file.
Here is a little tutorial to help you.
Just put the content of the one jar into the other jar (combine them). They are just zip files.
Is mylibrary.jar an executable jar file?
If so, you cannot reference external jars.
Related
I have made a library project that uses Async and Json/Gson libraries. It is working perfectly fine if I use this project as library project inside another Application Project. I don't want my code to be open to world so I tried to make a JAR of my Library Project. I am getting error that shows that the Async and GSON libraries can not be referenced.
Is my JAR not including the ASYNC and JSON libraries?
if not then how to do it? I have Checked the libs folder when exporting Library Project to JAR.
If Jar has included Libraries then why can't it get a reference? Is there any way that I can make a reference to the libraries present inside of the JAR of my library project?
Where am I making a mistake?
Update-1
Ok I have checked by extracting my jar and there is a lib folder there which has all the libraries that I have used in my Library Project.
Update-2
How I am exporting my Library Project as Jar.
Select Project to Export
Chose Jar File
Chose only src and lib folder.
Checked
Export generated class files and resources
Compress the contents of the JAR file
Chose Destination
Left All other checks as defaults and Finish.
I have *.so library and want to pack project into jar. Can someone help with problem how to force maven to pack native libraries so when i run jar they can be used?
i don`t want to add .so as new artifact. It is build also with maven before i build main java project so i just want to pack them into jar so i can use it.
Thanks.
I've copied resources before but couldn't read .so which was within the jar. So finally I've found Load library from jar and achieved my goal.
I made a simple standard-lone java Application using Spring,Apache Camel,Activemq for processing messages.
Note: My Application don't have any GUI.
My project structure is in the following way.
SACLib folder have nearly 70 external jars(all Spring,Camel and Activemq corresponding jars).
It's working fine in Eclipse. SO Now We want to deploy into Jar file.I tried in Eclipse,But I didn't seen Rod1,Rod2,Copy1 and SACLib folders in my Jarfile.
after Deploying Jar, If I run FirstConsumer.java it runs Rod1-->ThMapInfratab1-2.exe file. For this I mention Real paths of .exe file.
How can I make Jar file with including all my folders.
Thanks
Well, this is a kind of work that is typically done with build automation tools like Apache Ant, Maven or Gradle, so you can investigate there if you want to make this happen automatically next time.
But, if you want to do it manually...
First, you project needs a META-INF folder where you will place a file called a MANIFEST.
That manifest contains a Main-Class entry pointing to you main class. You can read about this in the Java Tutorial: Setting Application's Entry Point.
But it can also contain a Class-Path entry, pointing to all other jars required by your application and that should be loaded by the executable jar.
You can read about it the Java Tutorial: Adding Classes to your Jar Class Path.
If you are building your executable jar with Eclipse, it will let you choose the MANIFEST file that you want to use during the creation process.
Now, if you want to use build automation tools, there are other answers here that explain how to do it:
Creating a bundle jar with ant
How to create executable jar with dependencies with Maven
How to export an executable jar in Gradle
simply using ant download it , and then make a build.xml file and put it
Here's an simple example of an ant target that will create a jar (named test.jar) that includes all jar files under the lib directory. Maybe this will solve your problem?
for using apache ant, see this
http://ant.apache.org/manual/using.html
I have made a utility java project which contains XML, DB and other such utility classes. This requires 3rd party dependencies on some of the Apache common libraries, so I have added it in my java project by configuring the build path in eclipse Juno. Now I want to export this java project as jar file. When I am exporting this project as runnable jar file, it is working fine i.e if I include this jar in some other java project, I am able to access the utility classes, but when I am simply exporting the utility project as jar, I am not able to use it. Runnable jar requires a main class, but I don't want to keep a main class in my utility java project. I have compared both the jar files. The difference that I found out was that in runnable jar file, there is no .classpath file but a simple jar file that is in there. In the runnable jar file, all the jar files are mentioned in file named MANIFEST-INF.mf file, but in simple jar file it contains only version of .mf file. Can anyone tell me how can I make a jar file without a main class and use it for my other java projects so that I just have to include the jar file and use it as it is.
I assume it has not been provided in eclipse because extracting external 3rd party library classes in a utility project is something non-standard. It can result in a lot of problems as your project grows, class conflicts being one of them.
Still if you want to continue with your approach, yon can export your project as a normal jar project. Thereafter after open your project as well as the other third party libs in a utility like 7zip and drag-and-drop your third party library contents(except META-INF) into your project jar. That's all.
If you however want to automate it, ant would be your friend.
If you just export the project to jar file, you can package the jar(war) by using the apache ant tool.
Do something like this:
<jar destfile="${dist}/lib/app.jar"
basedir="${build}/classes"
excludes="**/Test.class"
/>`
We used an external library, specifically jmf.jar (Java Media Framework), for our java application which relies on images captured from the webcam. However, when we tried to package the application into a jar file, the application runs but once we try to access/open the webcam nothing happens.
We are using Eclipse and we used its export feature to create the jar file.
Does anybody know how to solve this?
Did you think to include jmf in the manifest of your jar ? See this link for more explanations here
You don't just need to export your project into a jar file; you need to create an "executable" jar file. This means that the manifest of the jar file is edited appropriately so that the classpath includes all required dependencies and the main class is set correctly.
In recent versions of Eclipse you can use the Runnable JAR File Export Wizard. Have also a look at the Fat Jar Eclipse Plug-in.
If you are using JMF you’ll need to include jmf.jar and jmf.properties in the same directory as the executable jar