Testing
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Testing
Last edited by Shivafeb17; February 1st, 2018 at 07:13 AM.
You can compile any blasted, bloomin' thing you want.
However to execute a Java application program, you need a public class with a public static void main(String [] args){} method. Like it or not, that is the rule.
To start execution with that main() method in that class, the file must be named according to the name of that public class (with a .java extension).
Reference: Java Tutorial Essentials, Part 1, Lesson 1: Compiling and Running a Simple Program
Still puzzled?
Then create a file with whatever classes and methods you want. Give the file whatever name suits your fancy.
Try to compile it.
If it compiles successfully, try to execute something in it.
If it doesn't work, look at the compiler error message(s) and if you still don't get it, show the exact, entire code and show the exact, complete message(s) and ask about whatever you don't understand.
Cheers!
Z
...
Last edited by Shivafeb17; February 1st, 2018 at 07:13 AM.
Correct me if I'm wrong, do you want to know whyis needed?public static void main(String Args[]) { }
As Zaphod_b said:
But in order to actually execute something at all, you'll have to include a main class somewhere. This is because Java executes the lines within the main first and foremost. Without it, stupid Java won't know where to start.You can compile any blasted, bloomin' thing you want.
....
Last edited by Shivafeb17; February 1st, 2018 at 07:13 AM.
I'm not sure what your problem or misunderstanding is. But to help keep things tidy you should place each class (except inner classes) in their own file. So class Fred is saved in Fred.java, class Barney is saved in Barney.java etc. It makes no difference what order you write or save files. When it comes to compiling you can: javac *.java and all files will be compiled or simply compile the class that contains the main method and all other classes will be compiled as needed.
Improving the world one idiot at a time!