how can divide my single programs in multifiles

I want to know that in java how can we divide our program among multifiles and then execute it.

for eg:
I made a new directory and inside that created these

class hello
public prnthello()
class hel
public static void main(String args[])
hello h=new hello();

then on command prompt i did:
it compiled successfully but gave the following runtime errors
D:PROGRA~1JAVA_P~1 rial>java
Exception in thread "main" java.lang.NoClassDefFoundError: hel/java
Caused by: java.lang.ClassNotFoundException:
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: Program will exit.

can anyone plz tell me the correct method to this


  • java hel

    NOT java

    Don't use the extension when running.

    Also, when compiling, you could use javac *.java instead.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion