This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes IDEs, Version Control and other tools and the fly likes Using JEE in Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Using JEE in Eclipse" Watch "Using JEE in Eclipse" New topic
Author

Using JEE in Eclipse

Kamil Kuchta
Greenhorn

Joined: Mar 09, 2009
Posts: 17
I want to use JavaMail which is a part of Java EE. I know that I can use standalone JavaMail librabry but it is not my purpose. I want to start using Java EE, and first use JavaMail classes.
I download and installed Java EE 6 SDK from
http://java.sun.com/javaee/downloads/index.jsp
Is it enough?

My question is, how can I use Java EE (for example use JavaMail classes) in Eclipse Classic WTP?
import.javax.mail.*; doesn't work. What should I do to import JavaMail from JEE platform?
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
I haven't yet used JavaMail, so someone please correct me if I'm wrong, but I believe JavaMail will be a service provided by the JEE container (application server). On which application server will you be deploying your application? Once you decide that, you then set the Targeted Runtime for your project in Eclipse to that application server and Eclipse will then include all the application server-provided Jars on the build path.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952
    
  19

If you're depending on an IDE for stuff like this, you're leaning on crutches.

I haven't been paying attention to the full-stack JEE implementations, but Tomcat doesn't include javamail in the container, so for Tomcat, at least, you have to include 2 jars in your WAR: javamail.jar and activation.jar.


Customer surveys are for companies who didn't pay proper attention to begin with.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
Tim Holloway wrote:If you're depending on an IDE for stuff like this, you're leaning on crutches.

I haven't been paying attention to the full-stack JEE implementations, but Tomcat doesn't include javamail in the container, so for Tomcat, at least, you have to include 2 jars in your WAR: javamail.jar and activation.jar.


What? The OP said that he was trying to use JavaMail from within Eclipse. My response was about using JavaMail from within Eclipse (or that was my attempt, anyway).

I don't know much about Tomcat, but it was my understanding that JEE containers (like JBoss) provide JavaMail.

Incidentally, the purpose of the IDE is to make the development process easier. I've had a long career using both IDEs and not using them. They each have their merits.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952
    
  19

We're have a strict "no-flame" policy on the JavaRanch, but after a few hundred "I'm using Brand X IDE how do I...: questions, I'll admit sometimes my patience gets a little strained. We are, after all, attempting to help people become more skillful on their own, and not just by leaning on specific products. Which is why if you should scan the IDE forum for the question "Which IDE should I use?", a very frequent response is "Windows Notepad".

Eclipse is not a JEE container. Unless suitable plugins are added, it has no JEE capabilities or knowledge at all. Eclipse is also not intended to serve as a JEE application server, since there's nothing it can add that the regular JEE appservers don't already supply. You use Eclipse to design, edit, maintain and debug JEE code. Therefore the concept of "using JEE in Eclipse" is technically incorrect unless you intend to write a JEE plugin that wants to send and receive email, such as perhaps an integrated email client.

It's fairly obvious that this wasn't what was intended here, however, and what was intended was the development of a JEE application using javamail. Which is perfectly possible without using Eclipse. And, as far as I know, Eclipse doesn't have any plugins for that purpose anyway, since it's not something that requires a whole slew of wizards, documentation aids, debugging tools, code generators and other appurtenances that make an IDE so useful.

If I seem sensitive on this subject it's because I've seen too many cut-rate programmers being employed to develop products that they don't understand using tools that - as far as they're concerned - operate by magic. There's just too much bad software out there already to make me happy with that.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
Tim Holloway wrote:We're have a strict "no-flame" policy on the JavaRanch, but after a few hundred "I'm using Brand X IDE how do I...: questions, I'll admit sometimes my patience gets a little strained. We are, after all, attempting to help people become more skillful on their own, and not just by leaning on specific products. Which is why if you should scan the IDE forum for the question "Which IDE should I use?", a very frequent response is "Windows Notepad".


Are you saying that I flamed you, or made you want to flame me? It seems to me your post was an overreaction. The OP wasn't asking which IDE he should use. This is a forum for IDEs, is it not? Why shouldn't we answer questions which might help users use IDEs?

Tim Holloway wrote:Eclipse is not a JEE container. Unless suitable plugins are added, it has no JEE capabilities or knowledge at all. Eclipse is also not intended to serve as a JEE application server, since there's nothing it can add that the regular JEE appservers don't already supply. You use Eclipse to design, edit, maintain and debug JEE code. Therefore the concept of "using JEE in Eclipse" is technically incorrect unless you intend to write a JEE plugin that wants to send and receive email, such as perhaps an integrated email client.

Neither the OP nor my response made any hint at the idea that Eclipse was a JEE container or an application server. I must be honest, I just don't see where your comments are coming from. I assumed from the OP's post that he was trying to develop an application which would be deployed to a JEE-capable application server.

Tim Holloway wrote:It's fairly obvious that this wasn't what was intended here, however, and what was intended was the development of a JEE application using javamail. Which is perfectly possible without using Eclipse. And, as far as I know, Eclipse doesn't have any plugins for that purpose anyway, since it's not something that requires a whole slew of wizards, documentation aids, debugging tools, code generators and other appurtenances that make an IDE so useful.


Again, I don't think the OP was asking whether or not he should be using Eclipse (or any IDE for that matter).

Tim Holloway wrote:If I seem sensitive on this subject it's because I've seen too many cut-rate programmers being employed to develop products that they don't understand using tools that - as far as they're concerned - operate by magic. There's just too much bad software out there already to make me happy with that.


Most of my development work (over the last 25+ years) has been outside of a formal IDE. I actually prefer it for most tasks. However, I don't feel it's my place to impose my will on other developers. If they want to use an IDE for a particular task, that's their decision.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952
    
  19

Kamil Kuchta wrote:
import.javax.mail.*; doesn't work. What should I do to import JavaMail from JEE platform?


You have to indicate that the javamail jar is part of your Eclipse build path using the Project Propteries/Java Build Path/Libraries tab . If your JEE container (JBoss, WebSphere or whatever) contains a javamail.jar file, that's normally the one you'd point to. The download you did is primarily useful for reference purposes but the actual container version is more authoritative for that particular container.

For Tomcat and for non-web-container JEE, like I said JavaMail isn't supplied with the container, so you'd have to download a copy if it's not in what you already downloaded:

http://java.sun.com/products/javamail/

There are certain build tools that will handle this for you automatically, such as Maven.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using JEE in Eclipse
 
Similar Threads
checking eclipse version
java JEE perspective problem
scea 6
Configuring Eclipse
Spring Framework in NetBeans