Solved

Problems with "Hello World" example

Posted on 2004-10-04
7
246 Views
Last Modified: 2010-03-31
I have this program:
****************************
class hello
{
   public static void main(String args[])
   {
      System.out.println("Hello World!");
   }
}
****************************
I saved this program to my hard disk as "hello.java", then I run "javac hello.java". After this I use: "java hello"  and I get this message: Exception in thread "main" java.NoClassDefFoundError: hello"

What do I have to add to my program, how do I compile it ???


0
Comment
Question by:probine
7 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 12215960
Try this:

java -classpath . hello
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12215965
set classpath=%classpath%;.
0
 

Author Comment

by:probine
ID: 12216043
I am going from the beginning, because it did not work:

1. I have installed Java under my "d:". It looks like "d:\Java"
2. When I compile the "hello.java" I do this:

- I move to the d:\Java folder, so I get this path:

D:\Java\bin>javac d:\Java\programs\hello.java

D:\Java\bin>java -classpath . hello

It doesn't work.

How do I register the path to javac and hava, so I do not have to always type the full path and how do I run this program ???
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
ID: 12216060
java -classpath d:\Java\programs hello
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12216084
You need to put the java bin directory on your path. Look up 'Environment variable' in Windows help
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12216118
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12216204
8-)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
servlet requestdispatcher include and forward differences 1 39
Java string replace 11 54
login form jsp example 2 37
ejb on wildfly 5 30
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…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.

856 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