Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

Exception in thread "main"

i have created a folder com. In this folder i have created the following file


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



I compile it using
D:\>javac com\Hello.java

But i am unable to run it. i get the following error
Exception in thread "main" java.lang.NoClassDefFoundError: com/Hello


when i do D:\>java com.Hello
Please help
0
niti20
Asked:
niti20
  • 2
1 Solution
 
objectsCommented:
try:

java -classpath d:\ com.Hello
0
 
objectsCommented:
or if you are running it from d:\ then you an use:

java -classpath . com.Hello

To avoid having to specify it on the command line then add d:\ to your CLASSPATH environment variable
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now