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.
Related
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
When i created the dynamic web project, i will have 2 folders with name Libraries and lib. So during the project i added .jar files as follows
Build Path --> Configure Build Path--> Libraries (tab) --> Add external JAR's -- > OK
When i do this, it will add files to Libraries, However i would like to add .jar files to lib folder.
I tried copying all .jar files from Libraries to lib, but it says
Copied .jar files directly to lib folder in directory structure, but i doesn't display in eclipse.
I would appreciate your suggestions and inputs.
Copy jars into WEB-INF/lib directory by copying files themselves (not from Libraries in eclipse view) and hit refresh from eclipse, they will appear in the Web App Libraries
P.S: It is almost always better to use a build tool like maven/ant to manage dependencies
Open the lib folder in the file browser and paste all the copied
jars.
Refresh the lib folder in the
I needed to add external jar files to a EAR Project.
I did add but the jar files are not reflecting in the lib directory, it is showing below to lib directory.
I added these jar files on right clicking on Deployment Descriptor, Import-> Java EE Utility Jar and choosing to copy from the folder.
When I dragged the jar file on the lib directory the velocity jar file gets changed to .ear file in the eclipse project explorer.
I have attached a snapshot of the project explorer. Could you please let me know how to add external jar files to ear project as my EJB requires external jars to be included.
I have even added classpath for jar files in my EJB manifest file
Class-Path: ErpServices-ejb.jar velocity-1.6.4.jar velocity-1.6.4-dep.jar xwork-core-2.2.1.1.jar
Looking forward to your reply. thanks.
Add those jars under folder EarContent/lib directly , then all is done.
I.E., EarContent/lib/foo.jar will work but EarContent/lib/dir/foo.jar won't.
A similar question : here
Just try project root folder right click properties -> build path -> add external jars
Instead of drag-and-drop, add it to the lib folder manually (outside the IDE), refresh the IDE, right-click the EAR project and in modules and dependencies, make sure that it is included in the lib folder and as a dependency.
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
I'm using Eclipse Helios and I was wondering how can I add a library project to my folder that will be copied to the build directory where my compiled project resides.
currently I did the following:
created a lib directory in the root of my project
copied the relevant jars to that dir
My Project -> properties -> Java Build Path -> add jars and I added all the jars from that directory.
after adding all the jars i got the following warning regarding each of the jar file:
jar will not be exported or published. runtime ClassNotFoundExceptions may result
first of all how can I add the directory of the jars instead of individual jars?
and the 2nd question is how can I do that the libraries will be deployed properly when compiling my application ?!
In eclipse Junu:
in a web project, after adding jar to build path,
one must add it to
Deployment Assembly
(in project properties)
when adding that jar to "Deployment Assembly" press the add button and select
Java Build Path Entry
(and not other workspace or file system option)
It can be about:
a simple refresh issue:
Can you switch to the navigator view, right-click refresh the project, make sure it's not in the LIB dir,
Then try and drag and drop the JAR into the lib dir and see if it shows up.
a process issue (from this cached blog entry, the original one being unavailable):
When you have total control of you web container/app server, deploying jar files is as easy as dropping the folder in your common lib folder.
If you don't package your web apps as a war file then it's even easier because you only have to drop the jars in the WEB-INF/lib folder of your webapp.
But if you don't have total control of your web server or application server, your only choice is to package the jars you've used with your war file.
While developing a web project using my recently developed utility(a jar file), I encountered a NoClassDefFound error. Of course, it's pretty obvious that the jar file I've made and using on my web project could not be found (not visible in the CLASSPATH).
Adding the jar to the build path only eliminated the compilation problem. Dragging the jar file into the lib folder of my Eclipse workspace isn't a very good idea.
It took me a couple of hours before I figured out the solution:
Right Click on your web project
Click Properties
Select J2EE Module Dependencies
Click the Web Libraries Tab
Add external jars (if the jar is outside of your project). An entry will be added under Jar/Module, make sure you click on the checkbox (checked).
And everything should be fine. I tried exporting to a war file and then checked the content and my jar files are indeed deployed with the war.
a project configuration issue
The OP ufk mentions in the comment:
I resolved the issue by:
adding a "Web App Libraries" library in "java build path" and
adding all the relevant jars into WebContent/WEB-INF/lib
I was facing the same problem, like whenever I export my web app as a war file, the external added jar files didn't get included in app/lib directory, causing exceptions during deployment.
you Have to switch the navigator view, right-click refresh the project, make sure it's not in the LIB dir (but in the project folder)
then try and drag and drop the JAR into the lib dir and see if it shows up.