1

I'm trying to use JavaMail API 1.4.6 in my project which uses Java 1.4 (required). I'm getting error:

[stderr] java.lang.NoClassDefFoundError: java.util.logging.Logger  
[stderr]    at com.sun.mail.util.MailLogger.<init>(MailLogger.java:104)  
[stderr]    at javax.mail.Session.initLogger(Session.java:227)  
[stderr]    at javax.mail.Session.<init>(Session.java:212)  
[stderr]    at javax.mail.Session.getDefaultInstance(Session.java:315)  

Where can I download the old java libraries to include in my project? I have only Java 1.7 installed on my Windows 8 PC.

Is it possible to use a different Logger library here, or try and older JavaMail API version?

4

3 回答 3

1

You mention in this comment that you're using the JRE on an embedded device (Ricoh printer). If you're referring to Ricoh's ESA then this claims to be J2ME, not J2SE. J2ME includes some but not all the standard J2SE classes, and java.util.logging appears to be one of those packages that is not included.

于 2013-03-07T14:27:55.620 回答
0

You can use Log4J library for logging. Its open source and you can download the same from

http://logging.apache.org/log4j/1.2/download.html

So, you can use your Java lib with this Log4j. You have to add this lin in your classpath.

Following is the simple configuration for Log4j

log4j.rootLogger=INFO, file, stdout

 log4j.logger.com.test.pkg=info
 log4j.logger.org.hibernate.SQL=STDOUT

# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=/tmp/test.log
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=7
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d %-5p [%t] [%c{1}:%L] %m%n

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %-5p [%t] [%c{1}:%L] %m%n
于 2013-03-07T13:18:30.710 回答
0

JavaMail 1.4.6 is the first release to add support for debug output using java.util.logging.

You can try downgrade to JavaMail 1.4.5 which doesn't depend on java.util.logging and use the com.sun.mail:android-activation:1.5.5 for the activation dependency if that is not already included with your Java Runtime. Out of the box, JavaMail doesn't support JavaME.

于 2016-10-19T20:48:22.783 回答