Exporting android project to jar (that includes other jars) - java

I've written a Android Game Engine library and would like to export it to a jar file. I've tried to do this with the following:
export > Jar File > Finish
As soon as I add the jar to the build path of another Android project, I get a little box in my code saying:
The type foo cannot be resolved. It is indirectly
referenced from required .class files
I believe this is because my Game Engine library includes other libraries in forms of jars.
How can I add those jar files to my Game Engine jar file?

You can decompile the other jar file using JDui, take what you need, and add it to your library. It all depends on how big is what you need..
Also, check whether you are using proguard in the export. You would have to be careful on how to configure it.

I assuming you are using Eclipse. You also need to use Properties->Java Build Path->Libraries->Add Jar button to add your jar file to the target project

Related

class not found exception in eclipse even though the user library containg jar file is in java build path

I have created a dynamic web project. A user library with a jar file is also created.
Then the user library has been added to the build path via
project properties--->java build path--->In libraries tab required user library has added and jar file is specified under it.
But exporting the project into the JBoss deployment directory is raising class not found exception over the class in added jar file.
How can I properly add a user library to my project's build path?
I'm not clearly understand your problem but there is nothing to discuss ;)
Because the Java EE Specifications and the application server are dictating how to place something in your app's classpath and that's it.
Here is the documentation:
https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7
If your problem is not regarding the result on the appserver, only something about comfor or project strcture you want in your IDE. Then use your build system (Maven) to do the job. Like bilding a jar and coping it to desired location etc.

How do I deploy a Java program in Eclipse?

I have a program I am making for a friend. It contains one class, references two libraries (sqlite4java and poi by Apache), and sqlite4java contains many native libraries (.so, .dll, .jnilib) that are within my lib folder. The program also reads and writes from a swimTeam.db file.
My question is how do I package this all into one program that can be run cross-platform? I have tried exporting the project as a runnable jar, but when I ran it it couldn't access the native libraries because they weren't exported. Any idea how to do this?
First thing is create a java project remove all the java files and copy all the Jar file you need to import into that project.
now add the the created project to your working project as "project references" (right click on the project and click on properties)
now add all the Jars in the Java buildpath->libraries
now export your project as JAR. open it and make sure that all the JARs u need are in it.

How to use *.jar file in a Java project?

I'm a complete novice to Java, and I'm stuck in trying to use an external jar library in a Java project I'm working on.
The library is Twitter4J (http://twitter4j.org/), a complex group of files which I can't understand how to include. I'm using Eclipse on Windows. I understood the meaning of CLASSPATH enviroment variable (or well, I think I did), but I can't understand how to link it to the Eclipse enviroment.
This blog post seemed to be what I was looking for: http://jasperpeilee.wordpress.com/2012/01/25/how-to-set-up-twitter4j-quickly-in-your-java-project/
But:
Add twitter4j-core-2.2.5.jar into project for general use.
1) Where should I copy the core file? In the /bin/ folder? Or in a completly unrelated /lib/ folder, as this question in SO stated?
Copy Twitter API property file into your project/bin directory.
2) What is the Twitter API property file?
3) How can I include JavaDoc jar files too? Is it possibile to get them into Elipse?
Any kind of help, even just a link, will be very appreciated!
You probably have a project folder for your Eclipse project. Go ahead and make a lib folder inside of your project folder, in the same directory as src and bin. There's nothing special about the lib folder specifically, it's just a convenient name. Copy the .jar file into your newly created folder. Back in Eclipse, right click your project and click Refresh. The lib folder should pop up, including your JAR! Right click the JAR file and go to Build Path --> Add To Build Path. At this point, any class in the project should be able to use Twitter4J features.
As for the What question, the Twitter API property file contains configuration that is necessary for the Twitter jar to function. The file should probably be located on the classpath of your application.
And the How question, you can attach the javadoc jar file of the Twitter jar to the Twitter jar's classpath entry in Eclipse. Right-click your project and select Properties. Go to the Java Build Path entry and find the Twitter jar under the Libraries tab. If you expand the Twitter jar entry you will see 'JavaDoc location'. You can specify the javadoc jar there.
In Eclipse, right-click your project, select Properties. Now find the entry for Java Build Path and select it. Click the "Libraries" tab if it is not already selected. Click the "Add external JARs..." button. Follow the prompts.

Build java library with resources

I am trying to make android java library, but when I build my project in output jar library placed only java compiled classes, but no resources and assets.
Also my project contains native libraries, I need to include it in jar too.
PS: I have connect my library project to another project.
PS2: I have find out that resources from library project (res, libs) compiles into apk file, but assets not. How to make assets compile too?
To export jar with resource file please follow the below steps.
1) Right Click on Project Folder
2) Then Click on Export
3) Click on Java -> Jar file.
4) It opens a Jar Export Dialog . Please ensure that Exported generated class file and
resource check-box is checked.
5) Then provide the export destination .
6) Finally click on finish button.
In export menu for eclipse, you have a check box asking you for the inclusion of source files

Add resources into a jar upon building

I want to add DLL's, images, textfiles etc to my project as resources so when I export it, the jar contains the resources so they can be used. I am using eclipse.
Problem is I have no idea how to add it. I've tried adding DLLs/pics to the src folder in the project, but when I export the jar, it is not located there
I've looked at How to make a JAR file that includes DLL files? but it only explains how to extract it, not how to add it to the project and build.
EDIT: I am using an applet to open the jar by the way, sorry for missing it!
Cheers
How are you opening the file in java?
Class.getResourceAsStream(name)?
If you are packaging the code in a jar, then you need to use that command. (as opposed to new File(name), which will get the file in the same directory as your jar)
If the file is not physically in your jar, you can check by changing .jar to .zip and extracting it, then check out this doc http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/javac.html
Usually in an eclipse project, the src folder is the wrong place to put non-sourcecode-content.
You should try moving to maven as your build system, as it is highly customizable and provides you with folders inside your project for exactly that purpose. (src/main/resources)

Categories

Resources