Link to home
Start Free TrialLog in
Avatar of seahpc
seahpc

asked on

JAvamail setup in Solaris

Hi Experts,

I am trying to run a java application to send out emails for me.
I have downloaded the javamail api and install in my system (solaris).

I tried to compile the msgshow.java(come with it) but I always enocunter the following errors.

# javac msgshow.java
msgshow.java:33: package javax.mail does not exist
import javax.mail.*;
^
msgshow.java:34: package javax.mail.internet does not exist
import javax.mail.internet.*;
^
msgshow.java:35: package javax.activation does not exist
import javax.activation.*;
^
msgshow.java:214: cannot resolve symbol
symbol  : class Part  
location: class msgshow
    public static void dumpPart(Part p) throws Exception {
                                ^
msgshow.java:288: cannot resolve symbol
symbol  : class Message  
location: class msgshow
    public static void dumpEnvelope(Message m) throws Exception {
                                    ^
msgshow.java:110: cannot resolve symbol
symbol  : class Session  
location: class msgshow
            Session session = Session.getDefaultInstance(props, null);
            ^
msgshow.java:110: cannot resolve symbol
symbol  : variable Session  
location: class msgshow
            Session session = Session.getDefaultInstance(props, null);
                              ^
msgshow.java:114: cannot resolve symbol
symbol  : class MimeMessage  
location: class msgshow
                MimeMessage msg = new MimeMessage(session, System.in);
                ^
msgshow.java:114: cannot resolve symbol
symbol  : class MimeMessage  
location: class msgshow
                MimeMessage msg = new MimeMessage(session, System.in);
                                      ^
msgshow.java:120: cannot resolve symbol
symbol  : class Store  
location: class msgshow
            Store store = null;
            ^
msgshow.java:122: cannot resolve symbol
symbol  : class URLName  
location: class msgshow
                URLName urln = new URLName(url);
                ^
msgshow.java:122: cannot resolve symbol
symbol  : class URLName  
location: class msgshow
                URLName urln = new URLName(url);
                                   ^
msgshow.java:141: cannot resolve symbol
symbol  : class Folder  
location: class msgshow
            Folder folder = store.getDefaultFolder();
            ^
msgshow.java:155: cannot resolve symbol
symbol  : variable Folder  
location: class msgshow
                folder.open(Folder.READ_WRITE);
                            ^
msgshow.java:156: cannot resolve symbol
symbol  : class MessagingException  
location: class msgshow
            } catch (MessagingException ex) {
                     ^
msgshow.java:157: cannot resolve symbol
symbol  : variable Folder  
location: class msgshow
                folder.open(Folder.READ_ONLY);
                            ^
msgshow.java:177: cannot resolve symbol
symbol  : class Message  
location: class msgshow
                Message[] msgs = folder.getMessages();
                ^
msgshow.java:180: cannot resolve symbol
symbol  : class FetchProfile  
location: class msgshow
                FetchProfile fp = new FetchProfile();
                ^
msgshow.java:180: cannot resolve symbol
symbol  : class FetchProfile  
location: class msgshow
                FetchProfile fp = new FetchProfile();
                                      ^
msgshow.java:181: package FetchProfile does not exist
                fp.add(FetchProfile.Item.ENVELOPE);
                                   ^
msgshow.java:182: package FetchProfile does not exist
                fp.add(FetchProfile.Item.FLAGS);
                                   ^
msgshow.java:194: cannot resolve symbol
symbol  : class Message  
location: class msgshow
                Message m = null;
                ^
msgshow.java:215: cannot resolve symbol
symbol  : class Message  
location: class msgshow
        if (p instanceof Message)
                         ^
msgshow.java:216: cannot resolve symbol
symbol  : class Message  
location: class msgshow
            dumpEnvelope((Message)p);
                          ^
msgshow.java:248: cannot resolve symbol
symbol  : class Multipart  
location: class msgshow
            Multipart mp = (Multipart)p.getContent();
            ^
msgshow.java:248: cannot resolve symbol
symbol  : class Multipart  
location: class msgshow
            Multipart mp = (Multipart)p.getContent();
                            ^
msgshow.java:258: cannot resolve symbol
symbol  : class Part  
location: class msgshow
            dumpPart((Part)p.getContent());
                      ^
msgshow.java:291: cannot resolve symbol
symbol  : class Address  
location: class msgshow
        Address[] a;
        ^
msgshow.java:299: package Message does not exist
        if ((a = m.getRecipients(Message.RecipientType.TO)) != null) {
                                        ^
msgshow.java:313: cannot resolve symbol
symbol  : class Flags  
location: class msgshow
        Flags flags = m.getFlags();
        ^
msgshow.java:315: package Flags does not exist
        Flags.Flag[] sf = flags.getSystemFlags(); // get the system flags
             ^
msgshow.java:320: package Flags does not exist
            Flags.Flag f = sf[i];
                 ^
msgshow.java:321: package Flags does not exist
            if (f == Flags.Flag.ANSWERED)
                          ^
msgshow.java:323: package Flags does not exist
            else if (f == Flags.Flag.DELETED)
                               ^
msgshow.java:325: package Flags does not exist
            else if (f == Flags.Flag.DRAFT)
                               ^
msgshow.java:327: package Flags does not exist
            else if (f == Flags.Flag.FLAGGED)
                               ^
msgshow.java:329: package Flags does not exist
            else if (f == Flags.Flag.RECENT)
                               ^
msgshow.java:331: package Flags does not exist
            else if (f == Flags.Flag.SEEN)
                               ^
38 errors


anyone encounter that before ?
help needed urgently.

Thanks
Avatar of johanvdv
johanvdv

Hello,

The Java compiler is trying to find the packages you are importing but he cannot find them.
You have to add the mail.jar and the activation.jar (these files are bundled in the API you downloaded) to the classpath before compiling the source file.
The packages you want to import are available in these jar's so you should be able to compile the source file then.

Johan
Avatar of seahpc

ASKER

i tried that, but still got the error....
Avatar of seahpc

ASKER

i tried that, but still got the error....
Avatar of girionis
 Tell us the exact steps you are taking.
Avatar of seahpc

ASKER

hi all,

thanks, i have manage to get it up.

thanks again for all ur kindness and help
So what exactly were you doing wrong?
Avatar of seahpc

ASKER

i follow the steps by coping the class files into some directory then set the classpath to the location. it doesn't work.

I the came across an article in some web pages, saying copy the files into the jre/lib/etx directory.
with this it works.
Hello,

The problem was your classpath. Just putting the classpath to the location of the JAR is not enough. You have to mention the complete jar file name in the classpath like this:

on Windows: set classpath=c:\myfolder\myJar.jar;c:\myfolder\mysecondjar.jar

and so on...

When you copy the JARS to the jre\lib\ext folder, the Java Runtime automatically uses the Jars in this folder in his classpath...

Johan
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- To be PAQ'ed and points refunded

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer
ASKER CERTIFIED SOLUTION
Avatar of SpideyMod
SpideyMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial