How to use jar file in Eclipse for android appllication [duplicate] - java

This question already has answers here:
How can I use external JARs in an Android project?
(12 answers)
Closed 9 years ago.
I am new in using jar files in Android application. While checking code for Android apps code.google.com suggested the jar files. I don't know how to use the classes from jar files. Please help me!
Thanks

Just put the jar in the libs folder of the project, then it will automatically be added to your project by Android SDK.
Now the code from the jar is accessible in your code.
If you added a jar containing the package org.jartest with the class IAmAnObject. You should be able to write IAmAnObject test = new IAmAnObject(), right click IAmAnObject in eclipse and select import org.jartest.IAmAnObject.

Create a folder that is called /libs at the root directory of your project, and put your jar files in there.

I don't know about eclipse.
The way you use a external library in an android project is by creating a 'libs' folder in the projects source folder and putting the jar files in their.
Don't forget to add the path of libs to the build path so they are available when building the final project (in eclipse it's right click the jar and select 'add to build path'
It has already been answered and a definite duplicate but I cannot seem to paste the answer URL.

Related

How do you edit a dependency/external library in android studio? [duplicate]

This question already has answers here:
How do I add a library project to Android Studio?
(31 answers)
Closed 7 years ago.
There is a lot of information about adding libraries and dependencies, but I haven't been able to find any useful information on being able to actually edit a library.
I have added https://github.com/jdamcd/android-crop as a dependency in my project, but I would like to edit some of its features, mostly layout related stuff. However, when I go into browse the files Android Studio says
"files under the build folder are generated and should not be edited" and when I edit them they are returned back to their pre-edited state once the system builds.
I also tried editing the files in notepad++ and the same problem occurs (they are returned to their pre-edited state on build).
Can someone tell me either how to edit the library or a workaround whereby I can change the layouts/some java without having to copy and paste the entire library into my project to make it editable?
Thanks in advance,
God speed.
Edit: The answer is instead of simply adding the library as a dependency in the build.gradle file using this code: compile 'com.soundcloud.android:android-crop:0.9.10#aar'
You have to add it as a module instead of just an external dependency, then you can edit the files.
If anyone is wondering how follows these steps:
Create library folder (call it whatever you want) in the root directory, i.e. the first folder you go into to get to the app and its contents.
Download the library, unzip it.
Put the folder from step 2 in the folder you created in step 1.
Add the module to the settings.gradle like so:
include ':LibraryContainingFolder:ActualLibFolder'
Sync and clean
Go to project structure in Android Studio, click on the main module, normally called app, click on dependencies tab, then click the green plus, then click "Module dependency".
The module should appear written as the containing folder and the library folder in it separated by colons 'something:somethingElse'. Add the module.
Sync, clean, buid etc.
You should add the library as a module in Android Studio, by downloading the code from the Github repository you're interested in (and removing the line under dependencies that you added to build.gradle)
Then follow the steps in this answer: https://stackoverflow.com/a/16639227/1065810

Need the JAR file for a javax.servlet.http.HttpServletRequest [duplicate]

This question already has answers here:
How do I import the javax.servlet / jakarta.servlet API in my Eclipse project?
(16 answers)
Closed 6 years ago.
I am modifying behavior of a web-app(server & client) running on web-sphere. I have de-compiled the code and just need to make minor changes and redeploy the code.
For this I made a simple Java Project with Eclipse EE and loaded all the de-compiled code. I only need the *.class files which I will convert to a JAR and place them at their proper place. The thing is there is a dependency which is not being resolved javax.servlet.http.HttpServletRequest so my project is not building
How to resolve this dependency?
If this dependency cannot be resolved than my guess is I could just get the JAR file for javax.servlet.http.HttpServletRequest and add to the Project's Build Path as an external JAR.
Where can I find the JAR for javax.servlet.http.HttpServletRequest
p.s. I am new to JAVA so I don't know much about HttpServletRequest also I am using Java 1.6 JRE.
A long time ago I used to manually add the servletapi.jar into my eclipse project, but that is a bad practice.
Now I just create a Dynamic Web Project, then add a server (usually Tomcat), then right click on the new project - select properties - select project facets and add the Tomcat Server as the runtime. It has the files you need. Once you hit the apply button and okay button it will resolve the missing import files.
Here is a step by step description from a similar question on SO: How do I import the javax.servlet API in my Eclipse project?
You'll want to add the Servlet API as a "provided" dependency. That is, you only use it to compile the code, but you don't need to package it with your web application since your web container will already contain a copy of it.
Just Download Servlet.jar file from below link.
http://www.java2s.com/Code/Jar/s/Downloadservletapi30jar.htm
add this jar file into your project using build path in eclipse.

Attaching the source to a library in eclipse [duplicate]

This question already has answers here:
How can I link source to a jar package in eclipse?
(4 answers)
Closed 7 years ago.
I downloaded this library for low level Java keyboard hooks:
http://ksquared.de/blog/2011/07/java-global-system-hook/
It works great, but I want to attach the source to it. The source is included as .java files, but when I go to attach them to the library in eclipse it only wants a jar or zip file. I tried zipping the .java files but it didn't work. I've never attached a source before, can someone help me out?
You can attach the source as either a zip file, a folder in the workspace or an external folder. In your project, right click and select Build Path -> Configure Build Path and then in the libraries tab find your library and expand it. There will be a line there about source attachment. On that like, hit the Edit button and then select the location of your source files.

Jars inside a Jar [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Clean way to combine multiple jars? Preferably using Ant
Include java libraries into own library
I have created a jar containing some custom code and a bunch of 3rd party jars. I don't want to explode the 3rd party jars that are in the jar created by me. I want to use this jar to build my webapp. Am using ant to do this. Please suggest a native/open source solution.
Since you are building a web app, you should be putting all the jars into the WEB-INF/lib directory of your war, using the ant <copy> task. The comments above are for putting jars inside other jars, but for your case, that is not what you want to do.
just export runnable jar file from eclipse adding library to the jar. when name of jar is asked under the textedit are three radio button where you can choose if you want to add jars, in app next .jar or inside it, or don't add it :)

Add android jar to eclipse

When I open the android jar I'm not able to see .java files , it shows .class files in it .
Please suggest me how to add android jar to eclipse.
Waiting for an early response.
If you want to check the java code of android you should better visit Andrdoid x-86 branch wesite and follow the instructions there.
But you can not see the java code by adding its JAR file in the eclipse project class path.

Categories

Resources