Solved

Problems with "Hello World" example

Posted on 2004-10-04
7
243 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
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…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

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

19 Experts available now in Live!

Get 1:1 Help Now