Solved

Problems with "Hello World" example

Posted on 2004-10-04
7
250 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
[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
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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

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 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 one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

729 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