I am having some issues with Java (OpenJDK Java 7 Runtime) on Ubuntu 12.04, and just want to make sure I have my CLASSPATH and JAVA_HOME variables set correctly.


Is my JAVA_HOME varibale set right here? I am wondering if it should be set to



My main issue I am having is with log4j

log4j:WARN No appenders could be found for logger (org.apache.fop.util.ContentHandlerFactoryRegistry).
log4j:WARN Please initialize the log4j system properly.

I have the file "log4j.xml" in a location on the classpath, so I am confused about the problem.

  • JAVA_HOME is the path to the installation directory. Usually /usr/lib/jvm/java-7-openjdk-i386 should do it. The classpath usually lists only directory paths - not individual jars. – Sridhar Aug 20 '12 at 21:39
  • Neither JAVA_HOME nor CLASSPATH are "required" to run Java apps. By convention, shell scripts invoking Java apps may use JAVA_HOME to point to one JVM when there's more than one installed, or it's installed in a non-standard directory not in the PATH. If not programming (ie: using multiple JVM's + mvn/ant etc), don't set it; just use (g)alternatives to put Java in your default PATH. If you do set JAVA_HOME, the executable is always $JAVA_HOME/bin/java. The var CLASSPATH is used by the JVM, but don't set it (very error-prone). Instead use the cmd line options for javac/java/ant/mvn. – michael Sep 29 '12 at 8:38
  • @sridhara a classpath usually lists actual jars. Directories are for "exploded" (unarchived) jars or other unarchived resources (such as log4j config.) (A directory of jars can also be specified: see askubuntu.com/questions/186693/… ) That being said, setting a global CLASSPATH is bad/wrong. Rather, there should be one classpath per individual application: thus use command-line options (e.g, java -cp dir1:dir2/foo.jar:dir3). (Note: depending on the tool, the cmd line option might be -classpath or just -cp). – michael Sep 29 '12 at 8:46
  • yes you're right @michael_n . not sure what I was on about. – Sridhar Sep 29 '12 at 13:20

If I understand correctly the problem is not with java. The problem is in your log4j.xml file.

Inside the class org.apache.fop.util.ContentHandlerFactoryRegistry it would have a : logger.error("Error Message/Exception") or logger.debug . . .

something along these lines and it is trying to write it to your logger that you have set up.

Essentially, you want to have something like

<logger name="org.apache.fop">
  <level value="info"/> 

in your log file that will pick up logging messages from that class.

if you have multiple appenders then add

<appender-ref ref="appenderName" />

underneath the level tag.

  • If an output log file was created, then the log4 config was found and this answer is correct. If no log file was created, the log4j config file was likely not found at all. Normally a log4j config should have a default appender including everything under "org.*" , "com.*", etc., to avoid errors like this. There's also a chance that this message was printed before logging was completely configured, and later log messages actually did make it to the log file. If this is your own app, then using slf4j instead of (or as a wrapper for) log4j will make your logging and your life much simpler. – michael Sep 29 '12 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.