I'm Visual Studios / C#, you can simply add a reference to a DLL file and then just use that namespace. I'm starting to dig into Android development and want to use the SimpleFTP library. Downloaded the .jar file, went to File --> Import and now I've got SimpleFTP.class and SimpleFTP.java in org\jibble\simpleftp in my Package Explorer.
But if I try to import org.jibble.simpleftp; it says it cannot be resolved. What have I done wrong?
I was hoping I could just start typing as if I had properly imported the library and it'd figure out how to correct my package, but no such luck =[
There are at least three solutions:
If you have the source code, you can place it under your src folder directly in your project.
If you have the source code, you can create an Android Library Project with the source code and connect your Android app projec to the library project.
If you have a JAR file, you can place it in the libs folder of your proejct.
Project -> Properties -> Java Path -> Libraries. There you can add your existing libraries, in several formats (jar, .zip, etc.).
Right click on your project and add build path
Related
I want to use the sentencer through the API in my Java program, which is very well documented here:
http://opennlp.apache.org/documentation/1.6.0/manual/opennlp.html#tools.sentdetect.detection.api,
and has also been described here:
How to use OpenNLP with Java?
I downloaded the apache-opennlp-1.6.0-bin.tar.gz from here: http://apache.lauf-forum.at/opennlp/opennlp-1.6.0/
But what I can't find anywhere is how to install OpenNLP such that I can import it in my Java programm. I tried to simply put the .jar in my workspace, which didn't help. I don't find any documentation on that on the OpenNLP page.
Ok, I think I figured it out myself.
I simply had to put the openNLP folder somewhere, then right-click the Project and go to
Build Path --> Configure Build Path
click the Libraries tab, click Add External JARs... and navigate to the OpenNLP jar file.
Then I could import classes, such as
import opennlp.tools.sentdetect.SentenceDetectorME;
without any problems.
I am trying to add Support Library v7 to my clean android project as support library (with resources). I followed every instruction here: http://developer.android.com/tools/support-library/setup.html#download and android.support.v7.* package is not visible in my main project.
Here is library reference in main project:
Support library project tree:
Support library project build path:
And finally, my main project tree
I don't see any errors in Problems tab, app compiles and runs normally but i cannot import android.support.v7 package which apparently isn't in build path in main project. I went through instruction twice in clean projects/workspace. I cleaned project, restarted Eclipse and nothing... All resources from library project are unreachable too.
Thanks in advance :)
Copy the library project to the folder where your android project is.
Select File > Import.
Select Existing Android Code Into Workspace and click Next.
Browse and import the same to eclipse
Once the library project is imported you can refer the same in your android project.
This is similar to setting up google play services in eclipse described here. Check the 4th step
http://developer.android.com/google/play-services/setup.html
It looks like android-support-v7-appcompat.jar is missing from your libs folder.
When you download the Android Support Library through the Android SDK Manager it makes the support .jar files you need available under {SDK Location}\extra\android\support.
To use the v7 files, copy these to your project's /libs folder.
android-support-v4.jar
android-support-v7-appcompat.jar
android-support-v7-gridlayout.jar (*if needed)
android-support-v7-mediarouter.jar (*if needed)
Typical gotchas (this looks OK in your setup):
Make sure the min SDK is at least API 7
Make sure the project target build is at least API 17
For more information about using the support V7 package (including running the v7 samples) can be found at the RHM Guide to Android Support Lib.
The issue seems to be in Absolute path in case of Windows base machine. I faced the issue of referencing support libraries When I moved Eclipse and related libraries to different drive than where the project was.
Copy paste the libraries to folder on same derive in a way that it can pick by relative path.
..\androidCommonlib\appcompat
android.library
I have a project whose source code is hosted in svn and I have checked out the source code already say in a folder "myfolder". The directory structure of my code is as follows:
myfolder/trunk/src/ is where my code resides. Now I create a Java project using eclipse using File -> new java project with the location to be myfolder/trunk/src/. When I do this, all the package structure gets changes and I have errors in my sources files.
It would be great if somebody can tell me what is the correct way to do this. I have found some articles on the internet, but the more I read the more I get confused.
Thanks
Vandana
You should have probably chosen to Import Existing Project into your workspace and you should try that instead. It works great as long as you have your .project file defined. To fix the errors you have now, Create a new src folder in your project and point it at trunk\src, so that it correctly recognizes all your Java files.
You probably should use myfolder\trunk as the root of your project, rather than myfolder\trunk\src. As Perception has mentioned, try to "Import Existing Project" first (rather than start a new project and point it at your source).
First, I assume you already have subversive/subclipse plugin installed in your Eclipse and you have used the right URL to import your source code.
Before checkout your source code, you may change your perspective to Java perspective.
Then you only need to use File-Import-SVN(choose SVN as your import source)-Checkout projects from SVN-Next-Give your project a Name-Finish.
If you have problem about installing SVN plugin, reference is http://subclipse.tigris.org/
http://www.eclipse.org/epsilon/doc/articles/epsilon-source-svn/
hi i am a new android developer. When i am searching for a logic related to my app in google, i found a java application which is related to my android app. After making some changes i succeded in getting output, but i need the code to be in an android based project. When i change to convert it i get lot of errors, is there any possible way to convert the java application into an android app by including any external jar file..... The java application is just a part of my android app, based on that i have to develop more so pls help me....
thanx in Advance
If you intend to include external Java code via .jar files, that is supported in Android. Just put the file into the libs/ directory of your Android project and use the classes as you would somewhere else.
If you are using Eclipse IDE, this might help:
After including the .jar files in the libs/ folder, right click on the required .jar file and select "build path", then click on "add to build path". After doing this, u'll notice that the .jar file is added in the "Referenced libraries" in your project. Once done, you are all good to go and import methods from these files. Hope that helps you remove your errors. Happy coding. :)
I have just started playing with Java, and I really like the language. I am using the NetBeans IDE, and I find one odd oversight. I can create a new class in a project, but NetBeans doesn't appear to support any way to import an existing class into a project.
I manage to get it done by going to some other project where the desired class already occurs, and then I copy/paste it into the source code folder of the new project, then change the package name at the top of the pasted file to match the package name of the new project.
Is there a nice direct way to do this from the NetBeans interface?
Thanks for any help on this.
In the Projects window you can expand the project that you are working on. Right Click on Libraries and select Add Project.... You will get a dialog allowing you to select another Netbeans Project with the Java classes that you wish to use.
You have to just make the .jar file of that/those java files which you want to use in another project.
right click on file->export->java->.jar then finish.
Now you can use these jar into your another project.
When you build the java project in netbeans it creates a jar file on the dist folder in the current project directory.
You can use this jar file for the other project as a package by adding this as ADD jar in the next project.I have tried this ,i am using my old project jar file for new project development.
Use the 'Clean and build' your project option from the netbeans application, that creates the 'dist' folder which you are looking for (and obviously can't find because you havn't cleaned&buld)
The netbeans itself creates .jar files and you can add the jar file to the current project you are working on.