Executing a Java Program

I am entirely new to shell scripting and would like to create a script to execute a java program called Main. I've already compiled it and placed the .java and .class files at /root/javaTest. Next I made a shell script that simply contained: java /root/javaTest/Main . I made the script executable and placed it in /usr/sbin. However, every time I try and run the script it tells me that the root.javaTest.Main class cannot be found. How do I just specify the path to the java class without the script assuming that it's part of the class name? This is probably a super noob x10 question, but I suck with everything Linux at the moment.

Thanks in advance for any help!

(1) You do not need the .java to run. Only the .class files will do.

(2) You do not run Java apps like that.

You set the classpath (using the -cp option) to point to the directory where you put your .class files.

Or you "cd" in your script to that directory before you call java. That may probably eliminate the need for -cp in simpler cases.

If your class containing the main() method is Apple, put in /root/test, then the command is simply like

java -cp /root/test:. Apple

or if the current working directory is /root/test this is just

java Apple

Thanks for the help, I appreciate it.