I've got a project running 1.7. I'm getting issues using javax.enterprise.context.RequestScoped. I'm confused as to why it isn't included as I have other javax.* libraries built into Netbeans by default.
Where can I download this library and how can I add it to my project?
By default, only the packages that are part of the Java Standard Edition are available. This library belongs to Java EE. Just go to project->properties->libraries->add library->Java EE Web 7 Api Library->add. That´s it.
It's part of the Java EE Specification. You should start your project within a container. In Netbeans use an Enterprise Application project type.
Try this:
You can import this jar file into your project.
Use cdi-api.jar
I found mine in glassfish folder
.\glassfish-4.1\glassfish\modules
Related
I am not able to add J2EE 7 libraries to my project in MyEclipse 10 while creating a new project .I want to use websocket api that is available with J2EE 7 in MyEclipse 10 .Is there any way to add those libraries and get content assist features for them
I don't think you can get content assist but you can use User Libraries to create your own library definition containing all the J2EE 7 jar files that you need. Remove the j2EE6 library from your build path and add your J2EE7 user library. You would have to alter the deployment policies for the project, or get it to use the Deployment Assembly to avoid the J2EE7 user library from being deployed (assuming the server you're using has the needed libraries).
If this doesn't help, try asking on the MyEclipse forums.
I am learning RESTful Web Services and all the tutorials use javax.ws.rs.* package. But with JDK 6 and JDK 7, my Eclipse doesn't seem to recognize javax.ws package. What am I missing here?
javax.ws.rs is not a JDK package; it is a server-side API that forms part of the Java EE specification. You would need to include a Java EE runtime on your classpath or source an implementation from a 3rd party if you're going the self-assembly route (e.g. using Tomcat.)
You're may be missing Jersey installation, or something in your environment configuration. Try also installing Eclipse WPT. You can follow this tutorial, it covers prerequisites and basic installation procedures as well.
How do I find which Eclipse version I have on my Ubuntu system?
This is what "About Eclipse SDK" says.
Eclipse SDK
Version: 3.5.2
Build id: M20100211-1343
I am not sure if its the Eclipse IDE for Java Developers or the Eclipse Classic version.
What I would like to do is use Eclipse for
Java based Web Application Development
Ant Builds
Deploy using Tomcat
including HTML, CSS Editing
Please help me decide which version I should choose? I would like to upgrade my Eclipse setup from whatever version it is now to a version that supports all the above. Should I go for Eclipse IDE for Java EE Developers?
Should I download a totally new version from Eclipse site or can I just ADD necessary features/plugins to my current Eclipse setup.
Please suggest.
See Compare Eclipse Packages for a nice chart
What I would like to do is use Eclipse for (...)
The Eclipse IDE for Java EE Developers allows to do what you're asking for out of the box.
Should I download a totally new version from Eclipse site or can I just ADD necessary features/plugins to my current Eclipse setup.
Both would work, although it would be simpler to just get directly the Eclipse IDE for Java EE Developers (especially if you don't know exactly what plugin(s) you're looking for). Personally, I don't use the version you can get from the repository but download Eclipse from the official website and install it in user mode.
If you are using Eclipse for only Enterprise Development, then as everybody has recommended I would use the Eclipse Java EE version. If you plan on occasionally using it for other development purposes then I would consider downloading a separate classic version as well.
The reason for this is that everybody is well aware of eclipse's plugin capabilities. Unfortunately, Eclipse can get bogged down with too many plugins or add on tools. What I have experienced is that if you are using it for Enterprise Development(J2EE) it might be a good idea to keep that as a separate environment then your other Java Development. That way you can download the plugins,tools,libraries,etc for your enterprise development, and you can use your classic version for any other development you might need.
The downside is you will have two versions, but this is not a problem granted you do not run them simultaneously.
If you want to play with Web development, then the Eclipse java EE for Developers is for you. It is shipped with components to make Java Enterprise applications to create Enterprise Applications (and bundle it in an Enterprise ARchiver, known as EAR file or Web ARchive, known as WAR file).
The default Eclipse shipping with Ubuntu is the Classic version, and you can add more plugins.
I would recommend, however, to download th eJEE version manually and unzip it and run. Then you have a local installation outside the system files.
I haven't been using Java extensively hence forget a lot fundamental things. Basically, I am working with a web-dynamic project (using Eclipse IDE with jdk 1.6), and during the build, I get errors that Cookie class and other web related classes cannot be found. What am I missing?
What Jars files do I need to add (and how)?
thanks
Think you need servlet-api.jar
Try here for any jar files you need http://www.java2s.com/Code/Jar/CatalogJar.htm
Sounds like you are missing servlet-api.jar
You can download it from the Maven repository.
Servlets are only part of the Enterprise Edition, not of the Standard Edition of Java. So you need the Java Enterprise Edition, AKA Java EE.
http://java.sun.com/javaee/
As others have said, you're missing the server api jar.
Having said that, downloading just the servlet api jar and not the server that goes with it means that you can't actually test your code.
In Eclipse, once you're installed a servlet container, such as Sun's Glassfish, Apache Tomcat, or Jetty, you can create a server instance of it so that Eclipse will compile against your server's servlet implementation. Creating a server instance also means that Eclipse's Run on Server command works.
IBM has a slightly outdated guide on Developing Web applications with Tomcat and Eclipse. The entire "Install the Web tools" section can be skipped if you have the Eclipse EE version, as Web Tools are already installed.
I have jdk1.6.0_13 installed, but when I try to find a javax.servlet package, or press Ctrl+Space in Eclipse after Servlet I cannot get anything. Where can I download this package, and why isn't it included in standard distribution for developers?
javax.servlet is a package that's part of Java EE (Java Enterprise Edition). You've got the JDK for Java SE (Java Standard Edition).
You could use the Java EE SDK for example.
Alternatively simple servlet containers such as Apache Tomcat also come with this API (look for servlet-api.jar).
A bit more detail to Joachim Sauer's answer:
On Ubuntu at least, the metapackage tomcat6 depends on metapackage tomcat6-common (and others), which depends on metapackage libtomcat6-java, which depends on package libservlet2.5-java (and others). It contains, among others, the files /usr/share/java/servlet-api-2.5.jar and /usr/share/java/jsp-api-2.1.jar, which are the servlet and JSP libraries you need. So if you've installed Tomcat 6 through apt-get or the Ubuntu Software Centre, you already have the libraries; all that's left is to get Tomcat to use them in your project.
Place libraries /usr/share/java/servlet-api-2.5.jar and /usr/share/java/jsp-api-2.1.jar on the class path like this:
For all projects, by configuring Eclipse by selecting Window ->
Preferences -> Java -> Installed JREs, then selecting the JRE you're
using, pressing Edit, then pressing Add External JARs, and then by
selecting the files from the locations given above.
For just one
project, by right-clicking on the project in the Project Explorer
pane, then selecting Properties -> Java Build Path, and then pressing
Add External JARs, and then by selecting the files from the locations
given above.
Further note 1: These are the correct versions of those libraries for use with Tomcat 6; for the other Tomcat versions, see the table on page http://tomcat.apache.org/whichversion.html, though I would suppose each Tomcat version includes the versions of these libraries that are appropriate for it.
Further note 2: Package libservlet2.5-java's description (dpkg-query -s libservlet2.5-java) says: 'Apache Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems, and provides a "pure Java" HTTP web server environment for Java code to run. This package contains the Java Servlet and JSP library.'
Have you instaled the J2EE? If you installed just de standard (J2SE) it won´t find.
The normal procedure with Eclipse and Java EE webapplications is to install a servlet container (Tomcat, Jetty, etc) or application server (Glassfish (which is bundled in the "Sun Java EE" download), JBoss AS, WebSphere, Weblogic, etc) and integrate it in Eclipse using a (builtin) plugin in the Servers view.
During the creation wizard of a new Dynamic Web Project, you can then pick the integrated server from the list. If you happen to have an existing Dynamic Web Project without a server or want to change the associated one, then you need to modify it in the Targeted Rutimes section of the project's properties.
Either way, Eclipse will automatically place the necessary server-specific libraries in the project's classpath (buildpath).
You should absolutely in no way extract and copy server-specific libraries into /WEB-INF/lib or even worse the JRE/lib yourself, to "fix" the compilation errors in Eclipse. It would make your webapplication tied to a specific server and thus completely unportable.
If you've got the Java EE JDK with Glassfish, it's in glassfish3/glassfish/modules/javax.servlet-api.jar.
those classes are usually part of servlet.jar
http://www.java2s.com/Code/Jar/wsit/Downloadservletjar.htm