aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Java Mail API in Unix Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java Mail API in Unix" Watch "Java Mail API in Unix" New topic
Author

Java Mail API in Unix

King Chin
Greenhorn

Joined: Aug 13, 2008
Posts: 11
I am trying to use Java mail API in Unix. I downloaded mail.jar nd activation.jar to windows machine and ftped it to Unix machine using command prompt. In the Unix machine I set the class path as below given in the downloaded files.

export CLASSPATH=$CLASSPATH:/home/.../mail.jar:.

export CLASSPATH=$CLASSPATH:/home/.../activation.jar (the "..." specifies the long directory structure)

When I compiled the code I got the error message as below.
javac mail.java
error: error reading /home/.../mail.jar; invalid END header (bad central directory offset)
mail.java:1: package javax.mail does not exist
import javax.mail.*;
^
mail.java:2: package javax.mail.internet does not exist
import javax.mail.internet.*;
^

Can anyone please help me. It would be a great help to me.
[ August 18, 2008: Message edited by: KingG Chin ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18903
    
    8

The error message says: your mail.jar file has been corrupted. There is something wrong with it. So get a new version.

(Perhaps you transferred it to the Unix machine using FTP but forgot to switch to binary mode?)
King Chin
Greenhorn

Joined: Aug 13, 2008
Posts: 11
Thank you. Can you please tell me how to switch to binary mode when ftping from commnad prompt in windows.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18903
    
    8

Well, assuming you are using the "ftp" program which looks like a command line itself, you type this command:
binary
King Chin
Greenhorn

Joined: Aug 13, 2008
Posts: 11
Very Thank you Paul. Now I am able to do it.
Pooja psharma
Greenhorn

Joined: Jan 29, 2008
Posts: 8
I tried including the 2jars...but I'm still getting the same error.
Even tried downloading the latest ones and ftping it under binary mode...but don't know why i still get this error.

i set my classpath as:
export CLASSPATH=$CLASSPATH:/tools/jdk150_18/jre
export CLASSPATH=$CLASSPATH:/export/home/.../SSL-jars/lib
export CLASSPATH=$CLASSPATH:/export/home/.../SSL-jars/mail.jar
export CLASSPATH=$CLASSPATH:/export/home/.../SSL-jars/activation.jar:.

and then try compiling my program...but get this:

$ javac SimpleMailExample.java
error: error reading /export/home/..../mail.jar; invalid END header (bad central directory offset)
lsSimpleMailExample.java:1: package javax.mail does not exist
import javax.mail.*;
^
SimpleMailExample.java:2: package javax.mail.internet does not exist
import javax.mail.internet.*;
^
SimpleMailExample.java:27: cannot find symbol
symbol : class Session
location: class SimpleMailExample
Session session = Session.getDefaultInstance(props,
^
SimpleMailExample.java:28: package javax.mail does not exist
new javax.mail.Authenticator() {

What is it that I'm missing here...please help!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Mail API in Unix