Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

charset problem

Posted on 2004-04-17
3
Medium Priority
?
971 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 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

722 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