Need the JAR file for a javax.servlet.http.HttpServletRequest [duplicate] - java

This question already has answers here:
How do I import the javax.servlet / jakarta.servlet API in my Eclipse project?
(16 answers)
Closed 6 years ago.
I am modifying behavior of a web-app(server & client) running on web-sphere. I have de-compiled the code and just need to make minor changes and redeploy the code.
For this I made a simple Java Project with Eclipse EE and loaded all the de-compiled code. I only need the *.class files which I will convert to a JAR and place them at their proper place. The thing is there is a dependency which is not being resolved javax.servlet.http.HttpServletRequest so my project is not building
How to resolve this dependency?
If this dependency cannot be resolved than my guess is I could just get the JAR file for javax.servlet.http.HttpServletRequest and add to the Project's Build Path as an external JAR.
Where can I find the JAR for javax.servlet.http.HttpServletRequest
p.s. I am new to JAVA so I don't know much about HttpServletRequest also I am using Java 1.6 JRE.

A long time ago I used to manually add the servletapi.jar into my eclipse project, but that is a bad practice.
Now I just create a Dynamic Web Project, then add a server (usually Tomcat), then right click on the new project - select properties - select project facets and add the Tomcat Server as the runtime. It has the files you need. Once you hit the apply button and okay button it will resolve the missing import files.
Here is a step by step description from a similar question on SO: How do I import the javax.servlet API in my Eclipse project?

You'll want to add the Servlet API as a "provided" dependency. That is, you only use it to compile the code, but you don't need to package it with your web application since your web container will already contain a copy of it.

Just Download Servlet.jar file from below link.
http://www.java2s.com/Code/Jar/s/Downloadservletapi30jar.htm
add this jar file into your project using build path in eclipse.

Related

How to add external third party jar in Notes Xpages application?

I am Java developer, recently working on Xpages project. we are using Notes 9.0.1. I created Java agent to send email and I want to use some third party jar, something like org.apache.commons.lang3 , end up this issue. how to add third party jar, like commons-lang3-3.4.jar, in my Xpages project?
I tried different ways
add jar under /jvm/lib/ext folder, restart DDE.the I can see it in
my project JRE system libray, but could not import in my Java code.
Maybe this is the way for server deployment.
add jar under /Code/Jars and then DDE generated with new name added in /Webcontent/WEB-INF/lib, but...
Add jar directly under /Webcontent/WEB-INF/lib, but not appeared /Code/Jars in Application view
add jar under the Java agent Archive folder, but...
None of them allows me import the package in my Java code.
Anything I did wrong, or is there any good way to add third party jar in XPages project.
Thanks
If you add a JAR to your project by importing it into /Code/JARs, it should be added so as to be accessible by your build path(2,3). The same is true of your /WebContent/WEB-INF/lib, but that may not be automatically defined in your version of DDE; for example, Domino Designer 9 has the design elements of /Code/Java and /Code/JARs, which didn't previously exist (these are separate folders/paths from /WebContent/WEB-INF/src or /WebContent/WEB-INF/lib, either can be in the build path). In either case, if your approach is to have the JAR in your NSF, make sure your build path has the path with your JARs. Separately you could add each JAR individually.
You can get to the Build Path via Project > Properties, then for the part of your build path concerning JARs, go to "libraries":
individual JARs in Project Build Path
JAR class path in Build Path (ex- /WebContent/WEB-INF/lib)
As for the path of using the /jvm/lib/ext folder approach, I've covered that in a blog post and it's important to remember to have the JARs in the appropriate relative path both on the server and in your Designer/local path (otherwise your local, DDE, may not pick up the change).(1)
For both, if you keep build automatically turned off, you'll want to make sure you perform another build to see the changes.
As for a Java Agent archive, this should just work and again I'm wondering whether your build automatically setting is enabled/disabled. The /jvm/ext/lib path ought to work for this as well (shown in my linked blog post).(4) *Note: as Paul Withers points out in the comments, importing a JAR to a Java Agent can introduce memory leak issues, making the /jvm/ext/lib/ path preferable.

class not found exception in eclipse even though the user library containg jar file is in java build path

I have created a dynamic web project. A user library with a jar file is also created.
Then the user library has been added to the build path via
project properties--->java build path--->In libraries tab required user library has added and jar file is specified under it.
But exporting the project into the JBoss deployment directory is raising class not found exception over the class in added jar file.
How can I properly add a user library to my project's build path?
I'm not clearly understand your problem but there is nothing to discuss ;)
Because the Java EE Specifications and the application server are dictating how to place something in your app's classpath and that's it.
Here is the documentation:
https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7
If your problem is not regarding the result on the appserver, only something about comfor or project strcture you want in your IDE. Then use your build system (Maven) to do the job. Like bilding a jar and coping it to desired location etc.

How to use jar file in Eclipse for android appllication [duplicate]

This question already has answers here:
How can I use external JARs in an Android project?
(12 answers)
Closed 9 years ago.
I am new in using jar files in Android application. While checking code for Android apps code.google.com suggested the jar files. I don't know how to use the classes from jar files. Please help me!
Thanks
Just put the jar in the libs folder of the project, then it will automatically be added to your project by Android SDK.
Now the code from the jar is accessible in your code.
If you added a jar containing the package org.jartest with the class IAmAnObject. You should be able to write IAmAnObject test = new IAmAnObject(), right click IAmAnObject in eclipse and select import org.jartest.IAmAnObject.
Create a folder that is called /libs at the root directory of your project, and put your jar files in there.
I don't know about eclipse.
The way you use a external library in an android project is by creating a 'libs' folder in the projects source folder and putting the jar files in their.
Don't forget to add the path of libs to the build path so they are available when building the final project (in eclipse it's right click the jar and select 'add to build path'
It has already been answered and a definite duplicate but I cannot seem to paste the answer URL.

Use external project in JSP

I downloaded a project from Google Code named 'mp4parser'.
Now I want to use it in my JSP page (specifically in a servlet).
How do I import it?
I use Netbeans.
In my project's properties I added a Library (Add JAR/Folder).
Then, in my servlet code I wrote
import com.googlecode.mp4parser.*;
But I get an error 'package don't exist'.
SOLVED
First I had to compile the mp4parser project, and then MANUALLY indicate the JAR file.
Netbeans couldn't find it on its own.
You should create jar of the project you downloaded and the add it to the class path and then you will be able to use it.
So you get compile time error ? The only problem that is happeing is your Jar is not in the Build Path. Please check How to add jar in netbeans

Jars inside a Jar [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Clean way to combine multiple jars? Preferably using Ant
Include java libraries into own library
I have created a jar containing some custom code and a bunch of 3rd party jars. I don't want to explode the 3rd party jars that are in the jar created by me. I want to use this jar to build my webapp. Am using ant to do this. Please suggest a native/open source solution.
Since you are building a web app, you should be putting all the jars into the WEB-INF/lib directory of your war, using the ant <copy> task. The comments above are for putting jars inside other jars, but for your case, that is not what you want to do.
just export runnable jar file from eclipse adding library to the jar. when name of jar is asked under the textedit are three radio button where you can choose if you want to add jars, in app next .jar or inside it, or don't add it :)

Categories

Resources