Eclipse Indigo (EE) + Java EE 6. Where are the classes in "javax.*"? - eclipse

I've just installed Eclipse Indigo for EE and Java EE 6 SDK/JRE from Sun. I need all those to compile a 3rd party Java project using the "javax.*" classes. What I cannot understand how to reach those classes?
How can I import or otherwise connect to "javax.*" classes inside Eclipse?

They're in the Java EE implementation. In other words, they're in the application server. For example, Glassfish, JBoss AS, Tomcat, etc.
In Eclipse, just integrate the target server in Servers view and associate the dynamic web project with it. You can select it during dynamic web project creation wizard:
or afterwards via Targeted Runtimes in project's properties:
Once associated the project with the application server, Eclipse will do all the necessary magic to make those classes available during compiletime. To verify it, the associated server should be listed as Library in project's Build Path property:
Note once again, you don't need to change/fiddle anything in there! If you did some attempts beforehand while shooting in the dark in order to "fix" this problem, then you should make sure that you've undone it all, or things may still go wrong.
See also:
How do I import the javax.servlet API in my Eclipse project?

Make sure you have all the settings in preferences set. Go to 'Window' -> 'Preferences' and then check the 'Installed JREs', point it to your newest and greatest jre within downloaded jdk. If that doesn't work, download jdk and eclipse Java EE again and start from scratch. Also make sure you have a java and javac added to your PATH (either on Linux or Windows)

Related

Do I need JDK to work with Eclipse Helios and Tomcat 7.0.33?

I want to develop dynamic web applications.
For this I am using Eclipse Helios and Tomcat 7.0.33. I have the JRE installed on my machine and I have provided the location of the JRE in the JAVA_HOME path.
But when I am running any servlet, I get the error:
" HTTP Status 404 " -- " The requested resource is not available
"
Do I need a JDK in place of the JRE (meaning I have to set the path of the JDK in place of the JRE)? Or could there be another other reason why this error is happening?
Looking for Help!
If your servlets are already compiled then JRE will serve the purpose,
But they are compiled then you will JDK and other libraries( like servlet-api.jar, etc.) to compile you servlets.
In short JDK is for development where you want to develop something using Java.
And JRE is used when you already have compiled classes and you just want to run it.
You might want to refer to this :
What is the difference between JDK and JRE?
In theory, compiling with Eclipse's incremental compiler is sufficient. Running the application server with a JRE should be fine as well. I suppose your error is somewhere else. Anyway, I'd strongly recommend installing a JDK for developing a Java application. It comes with some handy tools and many 3rd party tools (Maven, e.g.) also require a real JDK compiler and can't work with Eclipse's built in compiler.
I had the same problem. The JDK was not the issue. After you compile your servlet you have to restart your tomcat server so it can load your class files before you try to access it through the web browser. No more 404 errors after that, servlets are running fine.

Adding Java EE sources to an Eclipse project

Using Eclipse, I have configured one Java EE project to include in its class path the JBoss 7.1 Runtime.
(I did this with the "Add Library" button in "Project properties" -> "Java build path" -> "Libraries").
I use Maven to build the project and "normally" this works fine.
However, when I debug this application the Java EE source classes are not available. Just in case I took a look in the JBoss runtime but apparently the sources are not there. My main question is: Could someone please tell me what is the best way to add the Java EE sources to my Eclipse project so they will be available when debugging?
Also, if I am working with Maven is fine to add the Java EE libraries as the JBoss Runtime, as I am currently doing in my project? or it is considered a better approach to declare the dependency on Java EE in the project POM instead?
I started to wonder if the JBoss runtime approach was the "correct" way to add the Java EE binary classes, since strangely enough Maven from time to time fails compiling the application since it cannot see anymore the Java EE classes. I solve this deleting the JBoss Runtime from the build path (in the Eclipse project configuration) and adding them again. Fortunately, this compilation does not happen often, so I have been able to work doing this workaround until now.
Thanks for any feedback.

How do I - Incrementally deploy in debug mode and other wise using Eclipse Helios and JBoss Tools

Environment
Win7
Eclipse Helios, Eclipse 3.6.1
Java 6
Jboss Tools version 1.0.0.v20110123-0129-H10-CR1 from the nightly builds
Jboss 4.2.3
In the past I used MyEclipse, which is a paid tool. In myEclipse, it's easy to configure a JBOSS Server and then deploy
your webproject in it. While in debug mode, if I change a java class (OR JSP), its changes are immediately reflected under Jboss and
I can test that change, without doing any explicit redeployment
So myeclipse had these features working outof the box....
I'm trying to accomplish same functionality with Eclipse Helios and Jboss Tools
Case 1
I added the Jboss Server via Java EE perspective->Add Server etc...
And then added my WebProject to this Jboss Server
When I right click on this added project and publish from here, it runs an ant script, to create a single (Standard) war file...and it always does the whole thing over.
I dont get a choice to deploy it expanded and anything to specify an incremental deployment
Case 2
Since Case 1 didnt allow exploded war and anything incremental, I decided to use JBOSS Tools
So I opened, Window->Show View->Other->Jboss Tools->Project archives
Selected my webproject, after which it showed up in the "Project archives" tab
So then....Right click on the project name in "project archives" tab.....->New Archive->WAR...and I added my project to deploy in exploded form. ok.
Now if I right click on the added WAR and click "Build Archive (full)"....it deploys the whole web project. Everytime it does the whole thing, instead of incremental.
Since that option didnt do it incrementally, so I right clicked and clicked "Publish to Server". The window that pops up, doesnt show me any servers...from where do i add to this?
In summary....
A) I havent seen any way to incrementally deploy
B) When I'm in debug mode, my java file changes dont reflect immediately...I dont mind redeploying, but since its not incremental, its annoying to do the whole thing over and over.
So question is ...
1) How do I do an incremental deployment?
2) How do I configure this, such that my changes in java classes are reflected immediately when in debug mode.
btw I have seen people suggest an alternate soln to use a custom ANT script....But will ANT script incrementally deploy, if I use it's copy command?
Thanks
Amit
It's MUCH simpler than this.
Forget about JBoss tools Archives, simply use the WTP adapter that JBoss tools provides. This one does incremental deployment (like MyEclipse).
Make sure you install JBossAS Tools from JBoss tools (yes the name sucks). Its description is:
Provides a WTP adapter for JBoss AS 4.x and 5.x. Supports incremental and exploded deployment.
Dish the WTP Server adaptor you created earlier from "Add Server etc..." and do it again, but this time don't choose from "JBoss" but choose from the new folder "JBoss Community". You'll see several new adapters there with the red logo and a slightly different name (e.g. WTP bundled is JBoss v5.0 but the one supplied by JBossAS Tools is JBoss AS 5.0).
Alternatively you can also use JRebel, which does incremental deployment no matter what WTP adapter you use (you disable the automatic deployment in that case).

How to redeploy the web app using the Eclipse IDE

Im new to Eclipse. I use Tomcat as my run time server, but every time I modified the jsp pages, Eclipse was still displaying the older one. Just wondering how to redeploy the application so the changes can be reflected.
Eclipse: Eclipse IDE for Java EE Developers 1.2.1.20090918-0703
Tomcat: Tomcat 6.0
Thanks
Doubleclick the server instance in question in the Servers view to open its configuration. Now, in the right top you should see a section called Publishing. Open it to verify and configure autopublishing settings.
Eclipse should do that automatically for you.
Otherwise, on the Servers view (Menu Window->Show View->Servers), you can right click on your Tomcat instance and hit "Publish" or "Restart"
Make sure you have the "JST Server Adapters" ("Web, XML and Java EE Development category") feature installed.
Eclipse's publishing functionality requries the project to be a "web project", and in some cases requires additional configurations.
Go to Windows > Preferences > Server > Runtime environments and add your tomcat
Either try using publishing, or (better I think) use the FileSync plugin. There you can tell which folders from your project should be copied (live) to what directory on your machine (the tomcat/webapps/yourapp). With a little more effort the filesync configuration can be made machine independent (only using one parameter as TOMCAT_ROOT), in case you want to check-in the project to a repository where others will use it.
Get the Tomcat plugin. It was nice because you can install Tomcat on your system and then associate your web app with that instance of Tomcat. The plugin will let you stop/start Tomcat and define a server such that when you do a build it knows how to deploy the changes. There may be some newer plugin but the Tomcat plugin worked for me and was fairly simple to install and use. Here is a page from IBM on using Eclipse and Tomcat. Inside that page it points you to the following: http://www.ibm.com/developerworks/opensource/library/os-eclipse-tomcat/

What steps are necessary to get Eclipse and a Java servlet container integrated on Ubuntu 9.10?

What's the easiest way for me to get Eclipse running with a Java servlet container on Ubuntu 9.10?
I've tried a number of things, hitting dead ends each time. The best setup would use Ubuntu packages as much as possible, not require running Eclipse as root, and be able to debug running servlets.
Dead ends so far include run-jetty-run, the Sysdeo Tomcat plugin, and Eclipse WTP with tomcat6.
A big part of the problem is that the Ubuntu tomcat6 installation is non-standard, splitting directories such that they're not all in TOMCAT_HOME. Eclipse is also non-standard, and the usual plugin installation methods don't work. I got close by installing the WTP through a PPA, but I stumbled when trying to get it to recognize tomcat.
Ubuntu recently includes a pretty full Eclipse package that you can install via Synaptic or such. But I prefer to download my own.
I download from the Eclipse download site. If I choose Eclipse IDE for Java EE Developers then I have server environments for all Web app containers already built in. If I set up one for Tomcat (in Eclipse), Eclipse will download and install Tomcat for me. It's quite convenient, although I sometimes have trouble finding Tomcat or its files. Eclipse squirrels them away somewhere.
The server setup menus become accessible to you once you create a Web project (not plain Java project).
You should "apt-get install sun-java6-jdk", download and use the Java EE version of Eclipse, and then create a dynamic web project. In the web project create a jsp page, and right click -> "Run -> Run on server" where you may then install a server connector.
Some connectors are included in Java EE, some must be downloaded. Choose the one corresponding to the server you have downloaded and unpacked, and point Eclipse to the directory.
If all succeedes, the JSP page should then show up in a browser served from the started server.