Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problems with "Hello World" example

Posted on 2004-10-04
7
Medium Priority
?
253 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Accepted Solution

by:
CEHJ earned 200 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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 …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Suggested Courses

604 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