How to link an external jar file in two java projects - java

ok guys, I'm trying to import the jfugue android port library into a libdx project, but I don't know how to add the jar files from the core project to the android one, since they don't appear as jar in the add jar option in the android build path project.

The jar file you're pointing to is an external jar (you can see it has a full path), so add to the other project using "Add External JARs" button on the "Libraries" tab of the "Java Build Path" page of the project's properties dialog.

Step-1>Just copy the jar files from Quintas_analizer project and paste
them in libs folder of Quintas_analizer-android. Then right click on
the jar files in Quintas_analizer-android and add to build path.
or
Step-1.1 >Another way is that-> right click Quintas_analizer-android
->properties-> Android->Add-> Select the project Quintas_analizer and add.
If Quintas_analizer not shown then go to Quintas_analizer ->
properties -> Android-> Mark the checkbox ->is a library-> Repeat step
1.1

Related

Linking external source folder with name "src" in an eclipse project

This is NOT a question about linking source in eclipse java project
Is it possible to add an external folder named "src" in eclipse as the source folder.
The problem here is to keep the external folder name as "src" and not any other name; to do that I tried deleting src and bin folder from the standard eclipse java project and then tried to "Link Source" but that does not work.
Is there any other way I can make this happen?
That is make the Eclipse java project's src actually point to an external folder named "src"?
Similar issues with the out put folder "bin" as well.
System Information
OS: Windows 8, 32 bit
Eclipse: 3.7
Thanks.
You need to use Eclipse to remove the existing source folder from the project configuration, then delete it from the file system, then you can add the externally linked source folder as "src".
Right-click on the project and bring up "Properties..."
Click on "Java Build Path" and then the "Source" tab to show a list of the source folders on the build path.
Select "yourproject/src" and click the "Remove" button. This will remove it from the project (and the .classpath file).
Come out of it and physically delete the folder.
Go back to that dialog box and this time click "Link source...". It should work now. It works for me.
To make link with external folder, we need to rename the folder if any folder already exists with same name like "src" or better delete that folder. After that you can make link with the external folder using the anyone of the following method:
Method: 1 - (Make link manually via code):
1. Open the .project file from root folder of your workspace.
2. Include the below code with your file path:
<linkedResources>
<link>
<name>folder_name_list_in_your_project</name>
<type>2</type>
<location>folder_path_to_include</location>
</link>
</linkedResources>
3. Save the file and refresh the project to include the external folder in your project.
Method: 2 - (Make link manually via UI):
1. Right click the project, select "Build Path -> Configure Build Path".
2. Choose "Source" tab.
3. Click "Link Source" button.
4. Click "Browse" to choose the folder.
5. Enter the folder name in "Folder name" field to list the external name in your project.
6. If you need to add the pattern for include and/or exclude file, click "Next" and enter the pattern. Then click "Finish".
7. Otherwise click "Finish".
It works for me and hope that my steps also help you.
It is somewhat ugly, but you can create a hardlink in your filesystem. In the Windows command line, use mklink /H src d:\path\to\external\src.
I know that the following will hardly be useful, but: Think of a different approach.

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.

how to add. JAR in my project? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Adding a library/JAR to an Eclipse Android project
I found an interesting project to me, Wanted to use his library but I can not add to my library, as in the example
I do it in eclipse
I can not add. Jar in my library
Right click your project, select Build Path -> Configure Build Path.... On the Libraries tab you can add the library.
If the JAR is contained in a project folder select Add JARs.... If you want to add it from the file system select Add External JARs.
Right click on project Build path is displayed, take mouse over build path other option is displayed then click on configure build path
A new windows open check libraries is displayed at top navigation
Click on the libraries
Click on add External jar button
Browser your jar file
Add the file from the system.
As Piotr said, I didn't understand the problem. However, here is how you can add a jar file in eclipse.
Right-click on your project Build path -> Configure Build Path...
Select Library tab There you can see on the right-hand side, Add
JARs... or Add External JARs...
Select what do you want.
Copy the jars and paste them into your lib directory for web applications
lib location :
YourProject
--WebContent
---WEB-INF
---lib

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

How do you "install" Simple in eclipse?

How do I use simple in eclipse?
Do I add it to the JDK?
http://simple.sourceforge.net
The web site seem to have allot of info on using the methods but little on setting up the library.
I have used C and C++ to set up external libraries before but the Java set up confuses me.
Thank you!
In java world, in order to be able to use third party libraries, what you need to do is to add them to your project/application's CLASSPATH. In case of Simple, its library file is simple-xml-2.4.1.jar that is located inside a folder "jar" within the simple-xml-2.4.1.zip that you would download from Sourceforge.
Download and unzip the
simple-xml-2.4.1 Archive. (ZIP file).
Note that it has a Jar folder that
contains simple-xml-2.4.1.jar - that
is the library eclipse and other IDES
would use to set up the CLASSPATH
Goto your project in project
explorer.
Right-click on the project name and
select "Properties". Alternately, you
can click on the project name and
type "Alt+Enter". A window will
pop-up.
In the window, select "Java Build
Path". You will see several tabs,
including "Source", "Projects" and
"Libraries".
To add simple-xml-2.4.1.jar to your
project, click on the "Libraries"
tab. From there, you can add either
internal jars or external jars. The
"Add External Jar" would be to add a
jar that's on your computer somewhere
. So choose that button, browse to
where simple-xml-2.4.1.jar is located
and make sure to add it to your build
path

Categories

Resources