Solved

charset problem

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

829 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