why this program does not work?

I copy this from the java tutorial website. I have already put the text file in the correct place.

Q1. I choose run file in netbean, why the netbean generate the following error

init:

deps-jar:

Compiling 1 source file to C:\Users\Marco\io01\build\classes

compile-single:

run-single:

java.lang.NoClassDefFoundError: io01/CopyLines

Exception in thread "main"

Java Result: 1

BUILD SUCCESSFUL (total time: 0 seconds)

Q2. shouldn't the code be in this

[[public class CopyLines {

public CopyLines(){} .............]]

Q3. When should public CopyLines() be in the program, when should not?

import java.io.FileReader;

import java.io.FileWriter;

import java.io.BufferedReader;

import java.io.PrintWriter;

import java.io.IOException;

publicclass CopyLines{

publicstaticvoid main(String[] args)throws IOException{

BufferedReader inputStream =null;

PrintWriter outputStream =null;

try{

inputStream =

new BufferedReader(new FileReader("xanadu.txt"));

outputStream =

new PrintWriter(new FileWriter("characteroutput.txt"));

String l;

while ((l = inputStream.readLine()) !=null){

outputStream.println(l);

}

}finally{

if (inputStream !=null){

inputStream.close();

}

if (outputStream !=null){

outputStream.close();

}

}

}

}

[2724 byte] By [marco_wua] at [2007-11-27 8:11:40]
# 1
You don't have a package statement in the beginning of your file stating what package your class file belongs to.
maple_shafta at 2007-7-12 19:55:47 > top of Java-index,Java Essentials,Java Programming...
# 2
good! take me an hourCould you please give me idea on my Q3? thanks
marco_wua at 2007-7-12 19:55:47 > top of Java-index,Java Essentials,Java Programming...
# 3

> Q3. When should public CopyLines() be in the program, when should not?

Constructor rules:

1) Every class has at least one constructor.

1.1) If you do not define an explicit constructor for your class, the compiler provides a implicit constructor that takes no args and simply calls super().

1.2) If you do define one or more explicit constructors, regardless of whether they take args, then the compiler no longer provides the implicit no-arg constructor. In this case, you must explicitly define a public MyClass() {...}

if you want one.

1.3) Constructors are not inherited.

2) The first statement in the body of any constructor is either a call to a superclass constructor super(...)

or a call to another constructor of this class this(...)

2.1) If you do not explicitly put a call to super(...) or this(...) as the first statement in a constructor that you define, then the compiler implicitly inserts a call to super's no-arg constructor super()

as the first call. The implicitly called constructor is always super's no-arg constructor, regardless of whether the currently running constructor takes args.

2.2) There is always exactly one call to either super(...) or this(...) in each constructor, and it is always the first call. You can't put in more than one, and if you put one in, the compiler's implicitly provided one is removed.

~

yawmarka at 2007-7-12 19:55:47 > top of Java-index,Java Essentials,Java Programming...
# 4
hey marco,the program is running perfectly fine on my system without using any IDE. you must have some settings problem. and package name is not necessary here. i think yawmark has answered all your question quite well.regardsi_virus
i_virusa at 2007-7-12 19:55:47 > top of Java-index,Java Essentials,Java Programming...