Solved

charset problem

Posted on 2004-04-17
3
961 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
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

832 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