Skip to main content
deleted 154 characters in body; edited title
Source Link
Makoto
  • 107k
  • 29
  • 199
  • 236

Java problem: Could not find main class HelloWorld

I am new to java(a real novice).

I installed Java 1.7.0 in the following folder C:\Program Files\Java. My operating system is Windows XP(Version 2002) with Service pack 3.

The environment variablevariables which I set are

CLASSPATH : C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar;

Path : C:\Program Files\Java\jdk1.7.0\bin;

JAVA_HOME : C:\Program Files\Java;

  • CLASSPATH : C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar;

  • Path : C:\Program Files\Java\jdk1.7.0\bin;

  • JAVA_HOME : C:\Program Files\Java;

I have presented here the class names which are in my system.

Next I wrote a program(HelloWorld, HelloWorld.java):

import java.io.*;

class HelloWorld
{
    public static void main(String[] args) 
    {
        System.out.println("Hello World!");
    }
}

When I am compiling using javac HelloWorld.java it is compiling fine.

But after I issue java HelloWorld I am encountering the below error:

Error: Could not find main class HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:198)

Caused by: java.lang.ClassNotFoundException: HelloWorld
        at java.net.URLClassLoader$1.run(URLClassLoader.java:299)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:288)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:287)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:422)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:325)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:355)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:195)

After a bit of google searchsearching around, I found that may be something wrong in the environment variable. I tried to play with that but no luck.

I know that it may be a very simple thing for the real java developers(actually basic) but for me as of now no luck!

I even RESTARTED the machine and then again I tried to run but with same fate.

OS: Windows XP(Version 2002) with Service pack 3

Help needed .

Thanks .

Java problem: Could not find main class HelloWorld

I am new to java(a real novice).

I installed Java 1.7.0 in the following folder C:\Program Files\Java

The environment variable which I set are

CLASSPATH : C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar;

Path : C:\Program Files\Java\jdk1.7.0\bin;

JAVA_HOME : C:\Program Files\Java;

I have presented here the class names which are in my system.

Next I wrote a program(HelloWorld.java)

import java.io.*;

class HelloWorld
{
    public static void main(String[] args) 
    {
        System.out.println("Hello World!");
    }
}

When I am compiling using javac HelloWorld.java it is compiling fine.

But after I issue java HelloWorld I am encountering the below error

Error: Could not find main class HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:198)

Caused by: java.lang.ClassNotFoundException: HelloWorld
        at java.net.URLClassLoader$1.run(URLClassLoader.java:299)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:288)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:287)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:422)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:325)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:355)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:195)

After a bit of google search I found that may be something wrong in the environment variable. I tried to play with that but no luck.

I know that it may be a very simple thing for the real java developers(actually basic) but for me as of now no luck!

I even RESTARTED the machine and then again I tried to run but with same fate.

OS: Windows XP(Version 2002) with Service pack 3

Help needed .

Thanks .

Could not find main class HelloWorld

I installed Java 1.7.0 in the following folder C:\Program Files\Java. My operating system is Windows XP(Version 2002) with Service pack 3.

The environment variables which I set are:

  • CLASSPATH : C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar;

  • Path : C:\Program Files\Java\jdk1.7.0\bin;

  • JAVA_HOME : C:\Program Files\Java;

I have presented here the class names which are in my system.

Next I wrote a program, HelloWorld.java:

import java.io.*;

class HelloWorld
{
    public static void main(String[] args) 
    {
        System.out.println("Hello World!");
    }
}

When I am compiling using javac HelloWorld.java it is compiling fine.

But after I issue java HelloWorld I am encountering the below error:

Error: Could not find main class HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:198)

Caused by: java.lang.ClassNotFoundException: HelloWorld
        at java.net.URLClassLoader$1.run(URLClassLoader.java:299)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:288)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:287)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:422)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:325)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:355)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:195)

After a bit of searching around, I found that may be something wrong in the environment variable. I tried to play with that but no luck.

I even RESTARTED the machine and then again I tried to run but with same fate.

Source Link
Newbie
  • 1.1k
  • 3
  • 18
  • 36

Java problem: Could not find main class HelloWorld

I am new to java(a real novice).

I installed Java 1.7.0 in the following folder C:\Program Files\Java

The environment variable which I set are

CLASSPATH : C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar;

Path : C:\Program Files\Java\jdk1.7.0\bin;

JAVA_HOME : C:\Program Files\Java;

I have presented here the class names which are in my system.

Next I wrote a program(HelloWorld.java)

import java.io.*;

class HelloWorld
{
    public static void main(String[] args) 
    {
        System.out.println("Hello World!");
    }
}

When I am compiling using javac HelloWorld.java it is compiling fine.

But after I issue java HelloWorld I am encountering the below error

Error: Could not find main class HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:198)

Caused by: java.lang.ClassNotFoundException: HelloWorld
        at java.net.URLClassLoader$1.run(URLClassLoader.java:299)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:288)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:287)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:422)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:325)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:355)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:195)

After a bit of google search I found that may be something wrong in the environment variable. I tried to play with that but no luck.

I know that it may be a very simple thing for the real java developers(actually basic) but for me as of now no luck!

I even RESTARTED the machine and then again I tried to run but with same fate.

OS: Windows XP(Version 2002) with Service pack 3

Help needed .

Thanks .