Tech Support Guy banner
Status
Not open for further replies.
1 - 2 of 2 Posts

·
Registered
Joined
·
366 Posts
Discussion Starter · #1 ·
Hi, as part of my uni course I am required to learn Java. Until now, I have only used it at uni and everything works fine. However, I decided to download Java 2 SDK from the Sun website (version 1.3.1_01).

I am using Textpad as the editor and just installed Java by running the 32mb installer file. Textpad works fine and Java was installed to c:\jdk1.3.1_01

Now, i created this simple program (from my tutorial notes) in Textpad:

//
//
//
// The code below is held in a file called Exmpl1.java
//
//
//
// This is Example1
// The program requires you to type in your name.
// Your name and a welcome message are then output to the screen
//
//
import java.io.*;

class Exmpl1M
{
static BufferedReader keyboard = new
BufferedReader (new InputStreamReader(System.in));
static PrintWriter screen = new PrintWriter(System.out,true);

public static void main (String[] args) throws IOException
{
String name; // The place to store data entered from the keyboard

// Prompt to the user of the program
// ---------------------------------
screen.print("Please enter your name ");
screen.flush();
// Get the data (a name) entered at the keyboard
// ---------------------------------------------
name = keyboard.readLine();

screen.print("\n\nHello " + name );
screen.println(" - Welcome to programming with Java\n\n");

String lab; // The place to store data entered from the keyboard

screen.print("What lab are you working in? ");
screen.flush();
// Get the data (a lab) entered at the keyboard
// ---------------------------------------------
lab = keyboard.readLine();

screen.println("\n\n" + lab + "is a nice place to work!" );

} // End of method main

} // End of class Exmpl1M

I know this file works ok because i have tested it on the uni computers. The Exmpl1M.class file is created where the Exmpl1M.java file is stored. It will compile fine using the Tools>Compile Java menu option.

Now, here is the problem: when i go to Tools>Run Java Application, I get the message

"Exception in thread "main" java.lang.NoClassDefFoundError: Exmpl1M
Press any key to continue..."

Now, seeing as how i am new to Java, i have no idea why i am getting this message. Should I have changed any settings when i installed Java? I'm guessing it may have something to do with "method main" in the coding, but we have always been told to put this but not told why. :confused:

Please help cause i need to be able to write the progs at home too.
 

·
Registered
Joined
·
366 Posts
Discussion Starter · #2 ·
not got a clue what i did tho. Removed the SET CLASS PATH line in autoexec.bat, ticked all virtual machine options in IE and 'fixed' textpad which i was using to write java with and its all hunky dory now :)
 
1 - 2 of 2 Posts
Status
Not open for further replies.
Top