Click to See Complete Forum and Search --> : Simple problem


Happy.J
October 13th, 2001, 07:10 AM
I've already learnt Java. It's new to me.

I've created a folder called "JavaProg" in c: and a folder called "classOne" in "JavaProg". The program Test.java is stored in folder "classOne".

"JavaProg" used to hold the java programs for compiling.


The code as follows:

package JavaProg.classOne ;

import java.io.*;

public class Test {

public static void main(String[] args) {

int i = 5;

while (i <= 8) {

System.out.println("i = " + i );
i++;
}

} //End of main

}//End of Test

I compiled the program as follows
"C:\JavaProg>javac Test.java"


But it said it can't read the file. Why ?? i've inclued the package statement but it can't work!!!

The main purpose is that I would like to run a java program which is stored in another folder.


I don't understand the use of package statemnet.


Can any of you teach me?

Thank you for your help!

bayard
October 15th, 2001, 09:41 AM
Change the package name to just JavaProg

Then cd ..

Then do: javac JavaProg\Test.java

Make sure that '.' is in your CLASSPATH. ie) CLASSPATH=%CLASSPATH%;.
(where %CLASSPATH% is anything else you want in your classpath).

To run it:


java JavaProg.Test

Bayard
bayard@generationjava.com
http://www.generationjava.com

Brainbench MVP for Java
http://www.brainbench.com