Log4j issue
Log4j issue
(OP)
I am new to Java programming.
I have J2SDK1.5.0 in my machine
I was able find C:\Program Files\Java\j2re1.5.0 and C:\Program Files\Java\j2sdk1.5.0 and their respective folders with file.
I was trying to compile some java file which has log4j calling
The file Log4jDemo.java contains the following:
import org.apache.log4j.Logger;
public class Log4jDemo {
static Logger log = Logger.getLogger("Log4jDemo");
public static void main(String args[]) {
log.debug("This is my debug message.");
log.info("This is my info message.");
log.warn("This is my warn message.");
log.error("This is my error message.");
log.fatal("This is my fatal message.");
}
}
Before compiling i have extrated the log4j.jar from apache site file and kept at "C:\Program Files\Java\j2sdk1.5.0\lib" folder
I am able to compile file by
C:\Program Files\Java\test>javac -classpath "C:\Program Files\Java\j2sdk1.5.0\lib\log4j.jar" Log4jDemo.java
But when i do
C:\Program Files\Java\test>java Log4jDemo
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at Log4jDemo.<clinit>(Log4jDemo.java:5)
Why this error is coming?
please do help in resolving this ....
Regards,
Rk
I have J2SDK1.5.0 in my machine
I was able find C:\Program Files\Java\j2re1.5.0 and C:\Program Files\Java\j2sdk1.5.0 and their respective folders with file.
I was trying to compile some java file which has log4j calling
The file Log4jDemo.java contains the following:
import org.apache.log4j.Logger;
public class Log4jDemo {
static Logger log = Logger.getLogger("Log4jDemo");
public static void main(String args[]) {
log.debug("This is my debug message.");
log.info("This is my info message.");
log.warn("This is my warn message.");
log.error("This is my error message.");
log.fatal("This is my fatal message.");
}
}
Before compiling i have extrated the log4j.jar from apache site file and kept at "C:\Program Files\Java\j2sdk1.5.0\lib" folder
I am able to compile file by
C:\Program Files\Java\test>javac -classpath "C:\Program Files\Java\j2sdk1.5.0\lib\log4j.jar" Log4jDemo.java
But when i do
C:\Program Files\Java\test>java Log4jDemo
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at Log4jDemo.<clinit>(Log4jDemo.java:5)
Why this error is coming?
please do help in resolving this ....
Regards,
Rk
RE: Log4j issue
CODE
Tim
RE: Log4j issue
1).
C:\Program Files\Java\test>java -classpath C:\Program Files\Java\j2sdk1.5.0\lib\log4j.jar Log4jDemo
Exception in thread "main" java.lang.NoClassDefFoundError: Files\Java\j2sdk1/5/0\lib\log4j/jar
Problem still persists
2).
Set the Classpath first
C:\Program Files\Java\test>set CLASSPATH=%CLASSPATH%;C:\Program Files\Java\j2sdk1.5.0\lib\log4j.jar
C:\Program Files\Java\test>java Log4jDemo
Exception in thread "main" java.lang.NoClassDefFoundError: Log4jDemo
Problem still persists
3).
C:\Program Files\Java\test>java -classpath=.;C:\Program Files\Java\j2sdk1.5.0\lib\log4j.jar;%CLASSPATH Log4jDemo
Unrecognized option: -classpath=.;C:\Program
Could not create the Java virtual machine.
Problem still persists
4).
Copy the log4j.jar under C:\Program Files\Java\j2sdk1.5.0\ext\ (I have created an ext folder)
C:\Program Files\Java\test>java -classpath=. Log4jDemo
Unrecognized option: -classpath=.
Could not create the Java virtual machine.
Problem still persists
I have pasted Important env vars from set below:
C:\Program Files\Java\test>set
CLASSPATH=C:\Program Files\Java\j2sdk1.5.0\lib\log4j.jar
HOMEPATH=\
HOMESHARE=\\pun-home-01\rkondapa$
INCLUDE=C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\include\
JAVA_HOME=C:\Program Files\Java\j2sdk1.5.0
JDK_DIR=C:\Program Files\Java\j2sdk1.5.0
LIB=C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Lib\
Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\system32
;C:\WINDOWS;C:\PROGRA~1\VANTIV~1.5;C:\Program Files\Microsoft SQL Server\80\Tool
s\BINN;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\system
32;C:\WINDOWS;C:\PROGRA~1\VANTIV~1.5;C:\Program Files\Microsoft SQL Server\80\To
ols\BINN;C:\Program Files\Java\j2sdk1.5.0\bin;C:\Program Files\Java\j2sdk1.5.0\l
ib
Please do suggest the other ways
RE: Log4j issue
Tim
RE: Log4j issue
It is working with quotes.