So I have imported by two .jar files into the libs folder using the following method:
Right click on libs > Import > Import File System and then bring them in.
Once they get brought in, right click libs > Build Path > Configure Build Path and add them to the Build Path of the project.
However, when I imported the package I needed to use in my project, it gave me the error "The import org.codehaus cannot be resolved."
Any idea how to fix this issue?
Place the jars in the libs folder of your project as you have done. Then, right click on the jar, go to Build Path -> Configure Build Path. In the Libraries tab click Add JARs... and select the library jar. Then, go to the Order and Export tab and make sure that the library jar is checked.
Here's some info I found on integrating Jackson libraries: http://supersabrams.com/blog/?p=81
You only need to put them in the libs folder.
Remove them from the build path as this will cause problems with libraries declaration.
Related
I am new to Eclipse and Java, and I know that .jar files I need to add into libs derectory so that compiler could recognize them. How I can add .jars not only in libs folder but also in other folder too. How can I configure Eclipse to do that?
It's easiest if you have the jar files visible in the package explorer to start with, i.e. within your project directory. At that point, you can just right-click on the jar file, go to the "Build path" section of the context menu, then select "Add to build path".
If the jar file is elsewhere and you don't want to move it, you can right-click on the project, and under the "Build path" part of the context menu, select "Add external archives...". Then find the jar file in the file browser, and hit OK.
All of this can also be done from the project properties dialog, in the Java Build Path section.
Right Click project
Select Properties
Select Java Build Path
Under Tab Libraries Click on add jars or add external jar to add the required jars
The Java build path is used while compiling a Java project to discover dependent classes . It is made up of the following items:
Code in the source folders
Jars and classes folder associated with the project
Classes and libraries exported by projects referenced by this
project
Our goal is to feed our classes with the dependent classes present in the jars during compile time. Eclipse provies with number of easy ways to do it .Here you can find a good article about how to add the jars in the projects with screenshorts attached to it http://www.wikihow.com/Add-JARs-to-Project-Build-Paths-in-Eclipse-(Java)
In my project, I need to use external library. That library consists of .class files. I have added folder with this library to my project using properties -> Java Build Path -> Libraries -> Add class folder. I can compile project without any problem, but when I run it, I get failed resolving xy and debugger stops on line where I create instance of class from imported files.
I guess the external library I use isnt linked to my .apk file. How can I fix this? I have tried to check this library on "Order and Export" tab assuming that, it will export the library with my application. But it didnt work.
How can I link this library to my project .apk? Do I need to somehow install this library on device first? Do I need to copy this library in application folder?
PS: I'm using Eclipse Juno, android SDK target 10.
Thank you
UPDATE
I have this library copied in libs folder. External library path is:
my_project/libs/sk/aicit/leg/libraries*.class
I have added ./libs folder in Libraries settings of project.
I do not have .jar version of this library, only .class files.
I have also souce code of this library, but I didnt want to include its classes in my project, it has its own dependencies, I wanted to just "link" it like library. Its an external library I havent written.
UPDATE 2
I have copied all the source files from library to my projects "src/" dir. I have removed Library from Java build path. I can stil compile my project, but when I run it Iget
FATAL EXCEPTION:main
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{
com.example/myvideorecord/com.example.myvideorecord.Robot}: java.langNullPointerException
...
What can I do, how to debug this error? :(
steps
Copy the library file into libs folder
select jar file -> right click -> Build Path -> Add to Build Path
clean the project Project-> Clean -> select your project -> ok
Android Studio
For importing a Android library into Android Studio, use the following steps:
1) (Optional) I like having my main Android project contain everything it needs to compile correctly, so I move external libraries into the libs/ directory. Generally, you only need to keep the following directories:
res
src
AndroidManifest.xml
*.iml (This will typically be the name of the library you're importing.)
2) Go to your Project Properties.
3) Go to Modules.
4) Import a New Module (Command + N and then Import Module).
5) Navigate to the library directory you want to import.
6) Create module from existing sources.
7) Click Next three times to add the necessary files.
8) Click Finish to complete the module additional.
9) Click on your project in the module list and go to the Dependencies tab.
10) Click the + button at the bottom and click Module Dependency....
11) Make sure your library you're importing is selected and click OK.
12) Click OK in the Project Properties window.
And you should be good to go.
Copy that library file into libs folder
if u have the source code of the library you can import it in eclipse .
Right click on your project -> properties->android -> reference-> add
and add the library project which u have imported. This will include only .class files of the library in ur project
How to include (NOT ONLY reference) JAR file into existing project? I added it by using Project properties - Build path - add external jar's. But when I export my project, and then import it in another computer, this library was missing.
Drag it into your project view so it appears in the project as any other file.
Right-click the jar in the project view and add to build path.
Put your jars into a directory of your project e.g yourproject/lib so that external libraries are accessed through a relative path. And then use "Add JARs" option to add the jar to build path as in eboix's link.
You want to export your project as an archive (Export -> General -> Archive File), and then import your project as an existing project (Import -> General -> Existing Projects into Workspace). This way the project will be identical to the exported version and all of the configuration will be right.
Oh, and do what the other people suggest and copy the Jar file into the project so you don't have to reference it as an external Jar file (and everything is in one place).
I downloaded the .jar Jsoup file from jsoup.org/download. I then ran eclipse and imported the .jar files into a java project. However, I keep getting an error when I type
import org.jsoup.nodes.*;
I want to use the Document class in that file.
I made sure the syntax was correct and everything, but the error won't go away. Anyone know what the problem could be?
You need to add the JAR file to project's build path. Drop the JAR in the project's root folder or some /lib folder, rightclick the JAR file and then choose Build Path > Add to Build Path.
Unrelated to the concrete problem, using wildcard imports is not the best practice. Rather specify the imports separately, or just let Eclipse autocomplete it by entering Ctrl+Space after typing Document in the code.
Right click on project in Eclipse > Properties > Java Build Path > Add Jar > select the jar from your project which you imported before > ok
I am now going to use the .jar file on http://code.google.com/p/google-api-translate-java/. However, after I download it, I tried to import it in my current project folder (in Eclipse)
the two import statements
import com.google.api.translate.Language;
import com.google.api.translate.Translate;
always get complained by the compiler saying couln't find such class
Could any one help on how to correctly import this .jar file into a project in Eclipse?
You need to add it to your build path. Right-click on the project in Project View, select Build Path->Configure Build Path, then Libraries tab. Now, use one of available options there to add a JAR.
Use "Add JAR" if you copied the jar to your project folder or "Add External JARs" to add it by poiting to a path in filesystem. (Anyway, it is better to copy the jar to the project folder, in which you want to use the jar).
HTH
see How to import class into existing Java project, with Eclipse
Copy the google-api-translate-java-0.92.jar file to your project /WEB-INF/lib/ folder and refresh your project (right click on project and select "refresh").
Google Translate API v1 is deprectaed and will shutdown soon.
You can use Google Translate API v2 Java. It has a core module that you can call from your Java code and also a command line interface module.
Hy I have faced the same issue and fixed it
Step1: download google-translate-api jar file
step2: paste into your app library file
step3: Goto project structure > app > select dependencies -> then add path of your jar file...
Enjoy now you can acess google api services