how can divide my single programs in multifiles - Programmers Heaven

Howdy, Stranger!

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

Categories

how can divide my single programs in multifiles

jargonjargon Posts: 1Member
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

//hello.java
class hello
{
public prnthello()
{
System.out.println("hello");
}
}
//hel.java
class hel
{
public static void main(String args[])
{
hello h=new hello();
h.prnthello();
}
}

then on command prompt i did:
c:/>javac hello.java hel.java
c:/>java hel.java
it compiled successfully but gave the following runtime errors
D:PROGRA~1JAVA_P~1 rial>java hel.java
Exception in thread "main" java.lang.NoClassDefFoundError: hel/java
Caused by: java.lang.ClassNotFoundException: hel.java
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown 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: hel.java. Program will exit.

can anyone plz tell me the correct method to this

Comments

Sign In or Register to comment.