I am new to Eclipse IDE, I created a new project named "Hello World", and I need some APIs which are contained in a jar file.
I created a folder called "lib" under the project folder "Hello World" (parallel with src folder), and I import the .jar file into this lib folder, it extracts all the things to this lib folder automatically.
Then I created my HelloWorld.java class under src folder, however, when I put import ro.xxx.xxx.xxx, eclipse complains "the import ro cannot be resolved". Actually, the ro is under the lib folder.
I am stuck here. Shall I make this lib folder under the src folder instead of parallel with it? Please kindly give me some suggestions, thanks in advance!
Project -> properties -> Java build path -> libraries -> add external jars
Just Putting jar in lib folder won't work , you need those jars in your class path.
Here it is described how to add jars in to your build path in eclipse
Add the library to your build path.
Right mouse button on your project --> Build Path --> Configure Build Path...
Libraries --> Add jar
After you first create the lib folder parallel to the src folder you need to go back into Eclipse and Refresh the project so that Eclipse finds the new folder and jars. You can either highlight the project and hit F5, or use the right click menu off the project. After that the lib folder and jar files appear and you can right click a jar to add to the build path. If you add new jars subsequently you need to refresh again for Eclipse to find them.
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)
I am trying to develop java desktop application using eclipse and using some external jar file in project.
I have put that all jar file in /lib folder (this is desktop application so here /WEB-INF does not exist) now the problem is that the application cannot detect external jar file what is the problem ? and how I can solve this problem?
You need to add external jar file as :-
Click Properties > Java Build Path > Libraries.
Click Add External Jars and browse to the JAR file that contains the look and feel, then click OK.
Now, you are ready to apply the new Look and Feel to your application.
You have add it to classpath as well. right click on project and click add to build project.
click libraries tab and click external jar files. select your jar files. It will be added to classpath.
I think you have to inserti it. Rightclick in project properties build path, add external jar and browser to it.
just put jar file into the libs folder and abb to build path thats it. Updated eclipse not getting jar or configure file from the lib they get jar file from the libs folder.
You can right click on your jar file and choose Build Path and then choose add to build path
I new in Eclipse,Java and Linux. I search about this issue but I don't reach to answer. I want to write a program that manipulate HBase Tables. So I have some Jar files that they related to the HBase. In ordinary Java application I add Jar files through following instruction
Build Path -> Configuration Build Path -> Add External Jars
So in Dynamic Web Project sound like different. after some search I understand the Jar files must be added in WEB-INF/lib or in %TOMCAT_HOME%/lib. so I get answer from %TOMCAT_HOME%/lib but really stuck about how to add jar files in WEB-INF/lib. I copy all jar files in the folders but it doesn't work.
please help me in detail.
you are doing right....
Build Path -> Configuration Build Path -> Add External Jars
In "Order and Export" tab click on select all...
or coping file into WEB-INF/lib
Then just refresh your project and restart the server then deploy the project it will work fine...
as Cultor said its right process but you must be refresh project after adding jar files.
Build Path -> Configuration Build Path -> Add External Jars
To add jars in eclipse you have two options:
Right click on project got to properties-->click on java build path --> configure build path--> Libraries --> and select add external jars button.
It will open a window where you can add all your jars required.
Second option is to paste jars directly to lib folder.
lib folder is in Web Content --> WEB-INF --> lib.
Use any one of them.
You can copy jar files manually to WEB-INF/lib when you have your project open in eclipse, then while modifying build path, just click "add jars" button and refer a jar from WEB-INF/lib . By this when you deploy your project to tomcat, your WEB-INF/lib folder gets copied automatically.
You can drag the MySQL jar file from external folder where it is located in your computer into the lib of your project..
If a path to the jar file is too long it will not paste that jar file.
Paste the jar file on the desktop and try again.
This works for me.
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'm using Eclipse and I need to be able to add Java libraries (JAR files) into my web application's WEB-INF/lib folder. How do I achieve this?
Add the jar file to your WEB-INF/lib folder.
Right-click your project in Eclipse, and go to "Build Path > Configure Build Path"
Add the "Web App Libraries" library
This will ensure all WEB-INF/lib jars are included on the classpath.
Found a solution.
This problem happens, when you import a project.
The solution is simple
Right click -> Properties
Project Facets -> Check Dyanmic Web Module and Java Version
Apply Setting.
Now you should see the web app libraries showing your jars added.
Pasting the jar files in WebContent\WEB-INF\lib via the file system was the only way it worked for me.
They then appeared under the Deployed Resources and WebContent lib sub-folders.
When I looked, the build path had the jars in the Web App Libraries and everything built and ran fine.
They are automatically added to the project classpath if its a web project. Sometimes it does not work properly, a refresh or close/open of the project helps.
if its not a web project you can right click on the library and go to "Build Path" -> "Add to Build Path"
add the jar to WEB-INF/lib from file structure
refresh the project, you should see the jar now visible under the WEB-INF/lib folder.
add the jar to WEB-INF/lib from file structure
refresh the project, you should see the jar now visible under the WEB-INF/lib folder.
this is the best solution that worked for me
Check under project properties -> deployment assembly
if jar file are under deployed path- WEB-INF/lib
if not use add button and add jar under WEB-INF/lib
sometime eclipse (in my case Juno Service Release 2 ) was not doing it for me so i did manually. this worked for me.
From the ToolBar to go
Project> Properties>Java Build Path > Add External Jars.
Locate the File on the local disk or web Directory and Click Open.
This will automatically add the required Jar files to the Library.
In case this helps anyone, if you are using a Git repo, make sure the jars make it into the WEB-INF/lib INSIDE the git repo and not just in the project WEB-INF/lib
Add the jar file to your WEB-INF/lib folder.
Right-click your project in Eclipse, and go to "Build Path > Configure Build Path"
Add the "Web App Libraries" library
This will ensure all WEB-INF/lib jars are included on the classpath.
helped me..
Drag and drop in WEB-INF/lib folder and restart eclipse ans start webservice then create client