Solved

charset problem

Posted on 2004-04-17
3
959 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:
mayankeagle 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ArrayLists in ArrayLists/HashMaps? 4 40
java set up 1 47
HashMap Vs TreeMap 12 49
Java - Why doesn't this JFrame work 3 18
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now