Hello -
I can write, compile, and successfully run a Java program
to look at a .jar file and list the classes defined therein, but
I can't for the life of me get your "Using log4j" java code shown
in 1-2.17's INSTALL doc to work.
Perhaps there's some other magic that needs to happen to get
this code snippet you wrote to yield output?
----------------------------------------------------------------------------------------
You can now test your installation by first compiling the following
simple program.
import org.apache.log4j.Logger;
import org.apache.log4j.BasicConfigurator;
public class Hello {
private static final Logger logger = Logger.getLogger(Hello.class);
public
static
void main(String argv[]) {
BasicConfigurator.configure();
logger.debug("Hello world.");
logger.info("What a beatiful day.");
}
}
-----------------------------------------------------------------------------------------
I understand how CLASSPATH works, etc. I can get it to compile but
even if I again (with option -cp) specify exactly where the .class file is
that it just created from the compile, it still can't find what it needs.
Depending on where I've put things and what I tell it, I get one of these
failing results when I try to run the executable:
(1)
java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at Hello.<clinit>(Hello.java:6)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 1 more
Exception in thread "main"
or (2)
Error: Could not find or load main class Hello
Please, I am an old UNIX geek but this is really really frustrating me.
I have looked literally EVERYWHERE to find out what the problem is
but of course I am apparently the first and only person to ever have this
problem. Ha!
--
Please test what you build.