Solved

charset problem

Posted on 2004-04-17
3
965 Views
Last Modified: 2012-06-21
I try to compile and run the simple log4j example:

    import org.apache.log4j.Logger;
    import org.apache.log4j.BasicConfigurator;

    public class Hello {

      static 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 get the error:
WARNING: Default charset MS950 not supported, using ISO-8859-1 instead
Exception in thread "main" java.lang.NoClassDefFoundError: Hello

I'm using XP (Chinese). Should I need to set anything before running the program?

Many thanks.
0
Comment
Question by:andersy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Expert Comment

by:NTAC
ID: 10851897
Add charsets.jar to your classpath.  Go to System Properties->Advanced->Environment Variables-> then look up your classpath variable (Should be under system variables).  Then edit the classpath to include charsets.jar (should be in your javaxx/jre/lib/ directory.
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 50 total points
ID: 10856898
>> java.lang.NoClassDefFoundError: Hello

It means that the Hello class (your own class) is not found - it should be in the classpath.

Try: java -cp . Hello

Its better to add the path of the Hello class to the classpath, so add the Hello class's parent directory to the classpath, using: set classpath=%classpath%;C:\TESTS

- assuming that C:\TESTS contains the Hello.class file. Or you can add the current directory to the classpath:

set classpath=%classpath%;.

And run using:

java Hello
0
 

Author Comment

by:andersy
ID: 10860230
Thanks mayankeagle. It works after setting CLASSPATH.

BTW, the charset warning still prompts:

echo %CLASSPATH%
C:\jakarta-log4j-1.2.8\dist\lib\log4j-1.2.8.jar;C:\j2sdk1.4.2_04\jre\lib\charset
s.jar;.

java Hello
WARNING: Default charset MS950 not supported, using ISO-8859-1 instead
0 [main] DEBUG Hello  - Hello world.
0 [main] INFO Hello  - What a beatiful day.

Anyway, thanks NTAC.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question