Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Mail API in Unix

 
King Chin
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21149
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. Can you please tell me how to switch to binary mode when ftping from commnad prompt in windows.
 
Paul Clapham
Sheriff
Posts: 21149
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, assuming you are using the "ftp" program which looks like a command line itself, you type this command:
binary
 
King Chin
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very Thank you Paul. Now I am able to do it.
 
Pooja psharma
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic