This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

javax.mail, classpath and classpathx


Has anyone had any luck in getting javax.mail classes compiled from GNU
classpath?

Am I on the right track here?


I need to send emails where the subject and body are UTF-8 encoded, so
as to support the full unicode charset. My Java test program using Suns
classes work fine, but I'd like to use GCJ since the program that needs
this is a Windows C++ application where it is completely out of the
question to bundle a Java JRE for various reasons. I didn't find any
C/C++ libraries out there than can interface to SMTP *and* speak
unicode/wchar_t properly, so this seemed like a good excuse to play
around with GCJ.

Here is an account of my pitiful attempts:

- I fetched the files for classpathx from CVS and tried to compile.
After some fiddling around, I discovered how to get ./configure + make
going and I ended up with various .jar files. First I tried and failed
this under CygWin, but then I remembered my Linux machine in the closet
and voila!
- Alas, it appears that GCJ classpath compilation does not include the
classpath/inetlib classes. My attempts to compile classpath failed.


There was recently a discussion which was along the same lines:

http://gcc.gnu.org/ml/java/2003-03/msg00229.html


Ãyvind

// This is the first "missing class" from classpathx javax.mail
java.lang.NoClassDefFoundError: gnu/inet/util/Logger	at
javax.mail.Session.<init>(Session.java:106)	at
javax.mail.Session.getDefaultInstance(Session.java:363)	at
javax.mail.Session.getDefaultInstance(Session.java:393)	at
Send.main(Send.java:24)

// javax.mail example program sending a bit of Japaneese text.
import java.util.Properties;

import javax.mail.MessagingException;
import javax.mail.NoSuchProviderException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.Message;


public class Send
{

	public static void main(String[] args)
	{
		try
		{
			/** Set up session props and session. */
			Properties sessionProps = System.getProperties();
			String m_host="mail.broadpark.no";
			sessionProps.put("mail.smtp.host", m_host);
			Session m_session = Session.getDefaultInstance(sessionProps);
			MimeMessage message = new MimeMessage(m_session);
			String from="oyvind.harboe@zylin.com";
			message.setFrom(new InternetAddress(from));
			/** to is an array of type InternetAddress. */
			
			String to="oharboe@broadpark.no";
			message.addRecipients(Message.RecipientType.TO, to);
			
			String sub="";
			sub+=(char)0x79C1;
			sub+=(char)0x306B;
			sub+=(char)0x30D3;sub+=(char)0x30FC;sub+=(char)0x30EB;sub+=(char)0x304C;sub+=(char)0x3042;sub+=(char)0x3063;sub+=(char)0x3066;sub+=(char)0x3082;sub+=(char)0x3088;sub+=(char)0x3044;sub+=(char)0x304B; 
			System.out.println("Subject: " + sub);
			
			message.setSubject(sub, "UTF-8");
			
			message.setText(sub, "UTF-8");
			Transport transport = m_session.getTransport("smtp");
			transport.connect(m_host, "", "");
			transport.sendMessage(message, message.getAllRecipients());
			transport.close();
		}
		catch (AddressException e)
		{
			e.printStackTrace();
		}
		catch (NoSuchProviderException e)
		{
			e.printStackTrace();
		}
		catch (MessagingException e)
		{
			e.printStackTrace();
		}
	}
}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]