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?

tckmn
  • 57,719
  • 27
  • 114
  • 156
Matt
  • 129
  • 2
  • 13
  • Java 1.4 does include `java.util.logging`, are you sure you're definitely running on 1.4 or later? – Ian Roberts Mar 07 '13 at 13:16
  • That' weird, java.util.logging.Logger is part if Java 1.4 : http://docs.oracle.com/javase/1.4.2/docs/api/java/util/logging/Logger.html. You can download older Java-versions here : http://www.oracle.com/technetwork/java/javase/archive-139210.html – Don Mar 07 '13 at 13:17
  • (aside from the fact that it would be a really really good idea to upgrade your project to use a newer Java version if at all possible, as it's been years since 1.4 has had any security updates) – Ian Roberts Mar 07 '13 at 13:18

3 Answers3

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.

Community
  • 1
  • 1
Ian Roberts
  • 120,891
  • 16
  • 170
  • 183
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
Manoj Kathiriya
  • 3,366
  • 5
  • 19
  • 19
  • That won't help here, as it's the JavaMail library itself that depends on `java.util.logging`, not the user code – Ian Roberts Mar 07 '13 at 13:20
  • Ohk, in that best to download the lower version of JavaMailAPI, which compatible with Java 1.4. Other way is that you have to make Java compatible with JavaMailAPI lib. Let me try to find the link from where you can download the old version of Java + JavaMail API. – Manoj Kathiriya Mar 07 '13 at 13:23
  • Thanks for your involvment. The facts is that I'm bound to the JRE that is installed on an external device (Ricoh printer). And it should have Java 1.4.2, but looks like my JavaMail API doesn't want to use it's Logger class. – Matt Mar 07 '13 at 13:42
  • Is it using Sun JDK? And could you find Logger class in it? – longhua Mar 07 '13 at 13:49
  • Yes, it has j2re1.4.2_02 library and there is the Logger.class in it's resources... that is why it's making me confused even more – Matt Mar 07 '13 at 14:07
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.

Community
  • 1
  • 1
jmehrens
  • 10,580
  • 1
  • 38
  • 47