LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-19-2012, 06:00 AM   #1
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,622
Blog Entries: 29

Rep: Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896
package Flags does not exist - JavaMail


I downloaded JavaMail 1.4.5 from: http://www.oracle.com/technetwork/ja...ex-138643.html

Its README tells to put mail.jar in the path and then compile any of its demo examples.

$PATH:
Code:
bash: /home/anisha/qtsdk-2010.05/qt/bin/:/home/anisha/qtsdk-2010.05/bin:/home/anisha/openGTS17Nov/javamail-1.4.5:mail.jar:/usr/lib64/libreoffice/share/extensions/gdocs_2.1.0_modified/external_jars/activation.jar:/home/anisha/qtsdk-2010.05/qt/bin/:/home/anisha/qtsdk-2010.05/bin:/usr/lib64/mpi/gcc/openmpi/bin:/home/anisha/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib64/jvm/jre/bin: No such file or directory
Imports in the program:
Code:
import javax.mail.*;
Some of the errors I am getting:
Code:
msgshow.java:34: package javax.mail does not exist
import javax.mail.*;
^
msgshow.java:35: package javax.mail.event does not exist
import javax.mail.event.*;
^
msgshow.java:36: package javax.mail.internet does not exist
import javax.mail.internet.*;
^
msgshow.java:241: cannot find symbol
symbol  : class Part
location: class msgshow
    public static void dumpPart(Part p) throws Exception {
                                ^
msgshow.java:349: cannot find symbol
symbol  : class Message
location: class msgshow
    public static void dumpEnvelope(Message m) throws Exception {
                                    ^
msgshow.java:115: cannot find symbol
symbol  : class Session
location: class msgshow
            Session session = Session.getInstance(props, null);
            ^
msgshow.java:115: cannot find symbol
symbol  : variable Session
location: class msgshow
            Session session = Session.getInstance(props, null);                                                               
                              ^
msgshow.java:119: cannot find symbol
symbol  : class MimeMessage
location: class msgshow
                MimeMessage msg;
                ^
msgshow.java:121: cannot find symbol
symbol  : class MimeMessage
location: class msgshow
                    msg = new MimeMessage(session,
                              ^
msgshow.java:124: cannot find symbol
symbol  : class MimeMessage
location: class msgshow
                    msg = new MimeMessage(session, msgStream);
                              ^
msgshow.java:130: cannot find symbol
symbol  : class Store
location: class msgshow
            Store store = null;
            ^
msgshow.java:132: cannot find symbol
symbol  : class URLName
location: class msgshow
                URLName urln = new URLName(url);
                ^
msgshow.java:132: cannot find symbol
symbol  : class URLName
location: class msgshow
                URLName urln = new URLName(url);
                                   ^
msgshow.java:135: cannot find symbol
symbol  : class StoreListener
location: class msgshow
                    store.addStoreListener(new StoreListener() {
                                               ^
msgshow.java:163: cannot find symbol
symbol  : class Folder
location: class msgshow
            Folder folder = store.getDefaultFolder();
            ^
msgshow.java:179: cannot find symbol
symbol  : variable Folder
location: class msgshow
                folder.open(Folder.READ_WRITE);
                            ^
msgshow.java:180: cannot find symbol
symbol  : class MessagingException
location: class msgshow
            } catch (MessagingException ex) {
                     ^
msgshow.java:181: cannot find symbol
symbol  : variable Folder
location: class msgshow
                folder.open(Folder.READ_ONLY);
                            ^
msgshow.java:201: cannot find symbol
symbol  : class Message
location: class msgshow
                Message[] msgs = folder.getMessages();
                ^
msgshow.java:204: cannot find symbol
symbol  : class FetchProfile
location: class msgshow
                FetchProfile fp = new FetchProfile();
                ^
msgshow.java:204: cannot find symbol
symbol  : class FetchProfile
location: class msgshow
                FetchProfile fp = new FetchProfile();
                                      ^
msgshow.java:205: package FetchProfile does not exist
                fp.add(FetchProfile.Item.ENVELOPE);
                                   ^
msgshow.java:206: package FetchProfile does not exist
                fp.add(FetchProfile.Item.FLAGS);
                                   ^
msgshow.java:220: cannot find symbol
symbol  : class Message
location: class msgshow
                    Message m = null;
                    ^
msgshow.java:242: cannot find symbol
symbol  : class Message
location: class msgshow
        if (p instanceof Message)
                         ^
msgshow.java:243: cannot find symbol
symbol  : class Message
location: class msgshow
            dumpEnvelope((Message)p);
                          ^
msgshow.java:260: cannot find symbol
symbol  : class ContentType
location: class msgshow
            pr("CONTENT-TYPE: " + (new ContentType(ct)).toString());
                                       ^
msgshow.java:261: cannot find symbol
symbol  : class ParseException
location: class msgshow
        } catch (ParseException pex) {
                 ^
msgshow.java:280: cannot find symbol
symbol  : class Multipart
location: class msgshow
            Multipart mp = (Multipart)p.getContent();
            ^
msgshow.java:280: cannot find symbol
symbol  : class Multipart
location: class msgshow
            Multipart mp = (Multipart)p.getContent();
                            ^
msgshow.java:290: cannot find symbol
symbol  : class Part
location: class msgshow
            dumpPart((Part)p.getContent());
                      ^
msgshow.java:327: cannot find symbol
symbol  : class MimeBodyPart
location: class msgshow
        if (saveAttachments && level != 0 && p instanceof MimeBodyPart &&
                                                          ^
msgshow.java:331: cannot find symbol
symbol  : variable Part
location: class msgshow
            if (disp == null || disp.equalsIgnoreCase(Part.ATTACHMENT)) {
                                                      ^
msgshow.java:340: cannot find symbol
symbol  : class MimeBodyPart
location: class msgshow
                    ((MimeBodyPart)p).saveFile(f);
                      ^
msgshow.java:352: cannot find symbol
symbol  : class Address
location: class msgshow
        Address[] a;
        ^
msgshow.java:366: package Message does not exist
        if ((a = m.getRecipients(Message.RecipientType.TO)) != null) {
                                        ^
msgshow.java:369: cannot find symbol
symbol  : class InternetAddress
location: class msgshow
                InternetAddress ia = (InternetAddress)a[j];
                ^
msgshow.java:369: cannot find symbol
symbol  : class InternetAddress
location: class msgshow
                InternetAddress ia = (InternetAddress)a[j];
                                      ^
msgshow.java:371: cannot find symbol
symbol  : class InternetAddress
location: class msgshow
                    InternetAddress[] aa = ia.getGroup(false);
                    ^
msgshow.java:387: cannot find symbol
symbol  : class Flags
location: class msgshow
        Flags flags = m.getFlags();
        ^
msgshow.java:389: package Flags does not exist
        Flags.Flag[] sf = flags.getSystemFlags(); // get the system flags
             ^
msgshow.java:394: package Flags does not exist
            Flags.Flag f = sf[i];
                 ^
msgshow.java:395: package Flags does not exist
            if (f == Flags.Flag.ANSWERED)
What else do I need to do now?
openSUSE 11.4 64 bit.

java -version
Code:
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02, mixed mode)
UPDATE:

The code:
Code:
import javax.mail.*;


/**
 * copier will copy a specified number of messages from one folder
 * to another folder. it demonstrates how to use the JavaMail APIs
 * to copy messages.<p>
 *
 * Usage for copier: copier <i>store urlname</i> 
 * <i>src folder</i> <i>dest folder</i> <i>start msg #</i> <i>end msg #</i><p>
 *
 */

public class copier {

    public static void main(String argv[]) {
	boolean debug = false;	// change to get more errors
	
	if (argv.length != 5) {
	    System.out.println( "usage: copier <urlname> <src folder>" +
				"<dest folder> <start msg #> <end msg #>");
	    return;
	}

	try {
	    URLName url = new URLName(argv[0]);
	    String src = argv[1];	// source folder
	    String dest = argv[2];	// dest folder
	    int start = Integer.parseInt(argv[3]);	// copy from message #
	    int end = Integer.parseInt(argv[4]);	// to message #

	    // Get the default Session object

	    Session session = Session.getInstance(System.getProperties(), null);
	    // session.setDebug(debug);

	    // Get a Store object that implements the protocol.
	    Store store = session.getStore(url);
	    store.connect();
	    System.out.println("Connected...");

	    // Open Source Folder
	    Folder folder = store.getFolder(src);
	    folder.open(Folder.READ_WRITE);
	    System.out.println("Opened source...");	  

	    if (folder.getMessageCount() == 0) {
		  System.out.println("Source folder has no messages ..");
		  folder.close(false);
		  store.close();
	    }

	    // Open destination folder, create if needed 
	    Folder dfolder = store.getFolder(dest);
	    if (!dfolder.exists()) // create
		dfolder.create(Folder.HOLDS_MESSAGES);

	    Message[] msgs = folder.getMessages(start, end);
	    System.out.println("Got messages...");	  

	    // Copy messages into destination, 
	    folder.copyMessages(msgs, dfolder);
	    System.out.println("Copied messages...");	  

	    // Close the folder and store
	    folder.close(false);
	    store.close();
	    System.out.println("Closed folder and store...");
	    
	} catch (Exception e) {
	    e.printStackTrace();
	}

	System.exit(0);
    }
}

Last edited by TheIndependentAquarius; 11-19-2012 at 06:10 AM.
 
Old 11-19-2012, 06:31 AM   #2
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,622
Blog Entries: 29

Original Poster
Rep: Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896


The documentation had told me to set the CLASSPATH not the PATH.
Code:
export CLASSPATH=$CLASSPATH:~/openGTS17Nov/javamail-1.4.5/mail.jar:
Thanks to ATR from stackoverflow.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] kickstart install: "This package does not exist" after setting up the package. talltrees99 Red Hat 3 05-26-2011 01:41 PM
Javamail grob115 Programming 1 11-30-2010 10:26 AM
Use flags and package.mask question artur13 Gentoo 6 03-22-2010 09:43 AM
Javamail a7mlinux Linux - General 0 06-15-2009 04:22 AM
java - package does not exist error epoo Programming 2 06-05-2007 12:21 AM


All times are GMT -5. The time now is 11:22 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration