Eclipse JEE application

T

Tim Slattery

I've been a Netbeans user, but the powers that be have dictated that I
have to use Eclipse.

I've created a JavaEE "Dynamic Web Project". I've imported my struts
jars by copying and pasting (but there must be a way to find them from
within Eclipse). Then I create a Java class. I can use the classes
defined in the Struts jars, no problem there. But I cannot use things
like HttpServletRequest, HttpServletResponse, or HttpSession. It
doesn't know what they are. If I manually write the "import"
statements, it tells me "the import cannot be resolved".

It knows that this is a Java EE app, so why in the world can't it
figure this stuff out?
 
A

Arved Sandstrom

I've been a Netbeans user, but the powers that be have dictated that I
have to use Eclipse.

I've created a JavaEE "Dynamic Web Project". I've imported my struts
jars by copying and pasting (but there must be a way to find them from
within Eclipse). Then I create a Java class. I can use the classes
defined in the Struts jars, no problem there. But I cannot use things
like HttpServletRequest, HttpServletResponse, or HttpSession. It
doesn't know what they are. If I manually write the "import"
statements, it tells me "the import cannot be resolved".

It knows that this is a Java EE app, so why in the world can't it
figure this stuff out?
For something as generic as the JAR for the Servlet API and
implementation, one usually sets up a runtime (Tomcat, JBoss, WebSphere,
Oracle oc4j etc) and those libraries are then available to you.

A right-click under the Servers tab to get New->Server will get you started.

AHS
 
M

markspace

For something as generic as the JAR for the Servlet API and
implementation, one usually sets up a runtime (Tomcat, JBoss, WebSphere,
Oracle oc4j etc) and those libraries are then available to you.


At least in NetBeans, when you set up a type of "project," the base
libraries are put on your compile path. For example, when you choose
"Web Application," you don't have to do anything else to extend for
example HttpServlet.

A right-click under the Servers tab to get New->Server will get you started.


If this is the answer, then it is indeed a bit weird for someone from a
NetBeans background. Hopefully, you're answering about the compile-time
environment and not the run-time.

(NetBeans comes with a server, Glassfish, by default if you get the
"full Monty" (<-- air quotes), so perhaps that is why you don't have to
explicitly install one in NB. It always has at least one server to
compile against.)
 
A

Arved Sandstrom

At least in NetBeans, when you set up a type of "project," the base
libraries are put on your compile path. For example, when you choose
"Web Application," you don't have to do anything else to extend for
example HttpServlet.

I seem to remember that. I haven't used NetBeans for a couple of years,
and even then it was for a desktop app (a socket server actually). So
it's likely been 3 or 4 years since I fired up a web or full J2EE app on NB.

I do actually keep up with NetBeans dev. I have 6.9 and/or 7 installed
on two boxes right now, just in case. The reason I barely use it is
because no clients in the last 3 or 4 years have...it's almost always
Eclipse. I try to evangelize a bit but it's tough slogging.
If this is the answer, then it is indeed a bit weird for someone from a
NetBeans background. Hopefully, you're answering about the compile-time
environment and not the run-time.

Well, compile time and run time, it's somewhat indistinguishable. If
you're writing J2EE/Java EE with a typical app server there's the
expectation that most of your core stack is going to be supplied by the
server, not by the WAR/JAR/EAR. So your compile time requirements for
core Java EE APIs, and for your JSF, and for your persistence, and so
forth, are supplied by the server libraries - otherwise you are
maintaining two sets of dependencies.
(NetBeans comes with a server, Glassfish, by default if you get the
"full Monty" (<-- air quotes), so perhaps that is why you don't have to
explicitly install one in NB. It always has at least one server to
compile against.)

That's the difference, and Glassfish (or specific variants thereof) is
the Java EE reference implementation besides. Eclipse (at least all the
versions I've used) has elected not to include a server, but it does
have an easy-to-use server plugin system that handles most of the app
servers out there - you yourself obtain and unpack the server distro,
and the Eclipse server plugin for server X simplifies the process of
making Eclipse aware of it. I can typically set up and configure Eclipse
for Tomcat or JBoss or oc4j or whatever inside 5 minutes, once the
server distro is unpacked.

I have no objections to either approach, NetBeans or Eclipse. The
Eclipse approach is more realistic for me, as no client my company has,
has had, or ever will have, uses or will use Glassfish. :) So it's best
for me to go through the initial upfront setup for OAS or Websphere or
JBoss first on any given project. YMMV.

AHS
--
Governor Thomas was so pleas'd with the Construction of this Stove, as
describ'd in it, that he offer'd to give me a Patent for the sole
Vending of them for a Term of Years; but I declin'd it from a Principle
which has ever weigh'd with me on such Occasions, viz. That as we enjoy
great Advantages from the Inventions of Others, we should be glad of an
Opportunity to serve others by any Invention of ours, and this we should
do freely and generously.
-- Benjamin Franklin
 
T

Tim Slattery

markspace said:
At least in NetBeans, when you set up a type of "project," the base
libraries are put on your compile path. For example, when you choose
"Web Application," you don't have to do anything else to extend for
example HttpServlet.

Exactly right.
Nogo. I had already done that, before posting. I'd downloaded support
for Weblogic (our server), I'd created a "server" within eclipse. No
change.

If I now bring up project options and choose "Servers", I get a page
that says "This project is not associated with any servers." The only
other thing on the page is a "Restore Defaults" button and an "Apply"
button. Not very helpful.

There's a pane at the bottom of the Eclipse windows that has four
tabs" Markers, Servers, Data Source Explorer, and Snippets. CLicking
the "Servers" tab shows the WL server that I created, and says
[Started].
 
L

Lew

markspace said:
At least in NetBeans, when you set up a type of "project," the base
libraries are put on your compile path. For example, when you choose
"Web Application," you don't have to do anything else to extend for
example HttpServlet.

Exactly right.
Nogo. I had already done that, before posting. I'd downloaded support
for Weblogic (our server), I'd created a "server" within eclipse. No
change.

If I now bring up project options and choose "Servers", I get a page
that says "This project is not associated with any servers." The only
other thing on the page is a "Restore Defaults" button and an "Apply"
button. Not very helpful.

There's a pane at the bottom of the Eclipse windows that has four
tabs" Markers, Servers, Data Source Explorer, and Snippets. CLicking
the "Servers" tab shows the WL server that I created, and says
[Started].

You have to set up "runtimes". Context-menu the project, select "Properties"
and set up the "Targeted Runtimes".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top