How can I add a .jar to my build path in Eclipse? - java

I try to do it the following way:
Right click on the name of the project.
Click on Build Path in the drop dawn menu.
Click on "Configure Build Path"
And then I do not know what to do. Should I select "Source", "Projects", "Libraries", "Order and Export"?
In "Libraries" I have "Add JARs..." and "Add External JARs...". What should I select? (I have already a .jar file in the lib folder of my project.)
ADDED:
If I click on "Add JARs" in the "Libraries" tab, I see the "lib" sub-folder but if I go there I do not see my .jar file there (and I know that it is there).

Right click on the jar you want to add.
Build Path > Add to Build Path
You're done.
If you want to add the Library with the Java Build Path view, as you tried you have to use Add JARs. If you copied the library via File System the Project is not in sync. You could press F5 on the selected Project.
If you edit outside of Eclipse a lot, you can enable auto-refresh by going to Window > Preferences menu, then in the Preferences dialog box, select General > Workspace.
Check the Refresh automatically box.

I think you are almost correct in adding the jar files to the Selected Project
Right click on the name of the project.
Click on Properties in the menu.
Click on "Java Build Path"
Then select "Libraries"
In "Libraries" Click "Add External JARs...".(if the jar files exists outside the project)
Else Click "Add Jars" (if the jars Exists within the project)
Once you do this, workspace builds automatically and after that your application is set to use for the development.

Click "Add Jar" and select the jar from your project path.

If the jar is already in you project directory click "Add jar" in the Libraries-tab. If not click "Add external jar".
That should do it.
If your jar does not show up when you click "Add jar" although you have copied it to your project directory you should refresh your project. Just go to your project explorer in eclipse, right click on the project-name and click "Refresh".

Related

Complete procedures for deploying an Eclipse plugin

Currently I have a plugin project at hand. I want to export it as an archived zip file so my colleagues can simply grab the file and install it by themselves.
There are dependencies, icons, and some files in my plugin. Everything works in debug mode, but problems arise once I try to deploy the plugin.
Below are the approaches I have tried with no success.
Approach 1
Right click on my plugin project
Click "Export..."
Select "Deployable plug-ins and fragments"
Check my plugin
Under "Destination" tab, select "Archive file", then set the export path
Under "Options" tab, check "Package plug-ins as individual JAR archives" and "Allow for binary cycles in target platform"
Click "Finish"
The archive file contains a "plugin" folder with one jar file inside. Then, I copy the jar file to "C:\eclipse\dropins" and restart Eclipse. I can see my plugin there but an error will be generated if I run the wizard defined in the plugin, saying that the "Activator" class cannot be found.
Approach 2
Create a Feature Project
Enter a name and click "Next"
Select "Initialize from the plug-ins list" and check my plugin
Click "Finish"
Open "feature.xml" and go to the "Dependencies" tab
Click "Compute"
Save the file
Right click the feature project and click "Export..."
Select "Deployable features" and click "Next"
Check my feature in "Available Features"
Under "Destination" tab, select "Archive file", then set the export path
Under "Options" tab, select "Package as individual JAR archives" and check the two sub-checkboxes, check "Allow for binary cycles in target platform"
Click "Finish"
There are 2 folders and 2 jar files in the zip file. I copy the contents in both the folders "features" and "plugins" to their counterparts in my Eclipse folder. It is better this time, I can see my icon next to my wizard, but there is an error "Unexpected Exception: MyTestPlugin Feature does not exist (org.eclipse.jdt.core)".
I tried using different export options, and use the Eclipse UI (Help --> Install new software...) to install the plugin. They just did not work.
As I am new in this field, I would like to know how to export and import an Eclipse plugin.
Plugins should go under the "plugins" folder, and you may either unslect the "Package as individual jar archieves ... " option, or extract the generated "your_feature.jar" file as a folder, and copy that folder under the "features" folder of eclipse.

How can I remove old projects in Launch Configuration(Eclipse)

I made a java project(using eclipse) and tried to make it as runnable jar file(export)
Package Explorer -> right click the project -> select "Export" -> select "Runnable jar"
Then export window is created
You may see Launch Configuration, which is list of projects.
In this list, old projects is appeared. I do not use these projects anymore, so I want to remove this projects in list(Launch Configuration)
How can I delete it?
Open the 'Run > Run Configurations' menu. You can manage your configuration there.
If the launches are not listed there you will have to delete them manually from the workspace '.metadata/.plugins/org.eclipse.debug.core/.launches' directory.

import library to eclipse

I have been trying for hours to import a library to Eclipse. I tried the simplest method that seems to be to copy the folders inside a lib folder inside the project in Eclipse.
Inside the project folder, the folder of the library is lib/org/imgscalr
I am using the code
import static org.imgscalr.*;
What am I doing wrong? I dont know if there is any difference, but I am using a MACBOOK.
I'd like to say that I used the " refresh" and I can see the folder and files there...
If your library is a jar file, then right click the project name and navigate to Build Path.
Select Configure Build Path, and there the Libraries tab. Then choose "Add JAR" or "Add external JAR"(see here and here). The difference between these options is that "Add JAR" is for jars in the project directory, while "Add external JAR" allows for JARs locates anywhere else.
If your "library" is in the form of a folder with classes, follow the steps above but choose "Add Class Folder" instead of "Add JAR".

How to reflect another project's class info

there are two projects in eclipse! how to reflect one class in other project? I put other project's class path into system's property. but still popup class not found exception. Is there any good solution for it?
System.out.println(System.getProperty("java.class.path"));
System.getProperties().put("java.class.path",
System.getProperty("java.class.path") +
";C:\\Users\\fu.jian\\workspace\\Study\\bin");
System.out.println(System.getProperty("java.class.path"));
Class<?> forName2 = Class.forName("study.Activator");
System.out.println(forName2);
Right click the project to bring up the context menu.
Build Path->Configure Build Path
Under the Java Build Path dialog, select the Projects tab and add the project.
Try to add the project B to classpath of project A by:
In Eclipse click on project A -> mouse right click and select Properties -> Select Java Build Path -> Select Projects tab -> Click on Add... and check project B
The problem will be resolved inside Eclipse, if you use external tools for compilation and building the project - your problem will still appear.
You can export the project B as jar and copy the jar into the project A libs. This way you won't depend on Eclipse.

importing org.apache.commons.math.stat.StatUtils eclipse project

I am wanting to use the StatUtils in a project i am working on. How do i get the ability to import that package in my eclipse project?
Thanks
Right click on your project, then a menu will be showed, choose "Properties", click "Java Build Path" and choose "Libraries" tag, you can click "Add JARs..." or "Add External JARs..." to add the package you want.
You can refer to the website : http://www.wikihow.com/Add-JARs-to-Project-Build-Paths-in-Eclipse-(Java)
I guess this is the 2 option ^^
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftasks-114.htm -- good eclipse tutorial!
GL.
Point your browser to http://commons.apache.org/math/. Then read the instructions. Most particularly, download the jar file from the download area, and then add that jar file to your project's build classpath in the Eclipse build path options for the project.

Categories