File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes how to complie/run a java prog with 2 or more classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to complie/run a java prog with 2 or more classes" Watch "how to complie/run a java prog with 2 or more classes" New topic
Author

how to complie/run a java prog with 2 or more classes

abhishek ksv
Greenhorn

Joined: Aug 30, 2006
Posts: 1
I have 2 classes and iam using eclipse software.Now my public static void main function is in "class test" and another class exists say "class abcd".
now i have named the file as "test.java".
when i run it says tat no main function found..
what do i do and how to run a program like this.... and what to name the file as...



//package abcd;
import java.io.*;
import java.lang.*;

class abcd{
int size;
String breed;
String name;

void bark(){
System.out.println("bhow!bhow! "+size+" "+breed+" "+name);
}
}


public class test{
public void main(String[] args) {
abcd d= new abcd();
d.size = 10;
d. breed= "doberman";
d.name= "snoopy";
System.out.println("end of program");
}

}
Srikanth Basa
Ranch Hand

Joined: Jun 06, 2005
Posts: 241
It must be public static void main(String [] args)

You missed "static"
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

The main() function must be static :
static public void main(String[] args)


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to complie/run a java prog with 2 or more classes