Rajkumar.D
could not find the main class programm will exit - error
2 Answer(s)      4 years and 7 months ago
Posted in : Java Beginners

when i tried to run the below mentioned programmed it gives a error states - could not find main class programm will exit.

class Car { String name: String Color: int num: } public void accept(){ name = "BMW"; Color = "Block"; num = 1234; } public void disp(){ System.out.println("Name of the Car is: " + name); System.out.println("Color of the Car is: " + Color); System.out.println("Number of the Car is: " + num); } public static void main (String ars[]){ Car c = new Car(); c.accept(); c.disp(); }

Advertisement
View Answers

October 29, 2010 at 2:11 PM


Hello Friend,

Try this:

class Car { String name=""; String Color=""; int num=0;

public void accept(){ 
    name = "BMW"; 
    Color = "Block"; 
    num = 1234; 
    } 
    public void disp(){ 
    System.out.println("Name of the Car is: " + name); 
    System.out.println("Color of the Car is: " + Color);
    System.out.println("Number of the Car is: " + num); 
    }
    public static void main (String ars[]){
        Car c = new Car();
        c.accept(); 
        c.disp(); 
        } 
        }

Thanks



October 29, 2010 at 2:12 PM


Hi Friend,

Try this:

class Car {
    String name="";
    String Color="";
    int num=0;

    public void accept(){ 
        name = "BMW"; 
        Color = "Block"; 
        num = 1234; 
        } 
        public void disp(){ 
        System.out.println("Name of the Car is: " + name); 
        System.out.println("Color of the Car is: " + Color);
        System.out.println("Number of the Car is: " + num); 
        }
        public static void main (String ars[]){
            Car c = new Car();
            c.accept(); 
            c.disp(); 
            } 
            }

Thanks










Related Tutorials/Questions & Answers:
.jar file keeps giving me " could not find the main class". Program will exit.
.jar file keeps giving me " could not find the main class". Program will exit... click on it, it gives me the message" could not find the main class. Program... netbeans's project properties clearly sets testing2.hihi as my Main class and I have
could not find a getter for id in contact class
could not find a getter for id in contact class   could not find a getter for id in contact class
Advertisements
programm
Multiplication import java.util.*; class MatrixMultiplication{ public static void main(String[] args){ Scanner input = new Scanner(System.in); int
is this programm efficient to find the day of the given date . can it be more normalized ?
is this programm efficient to find the day of the given date . can it be more normalized ?  #include <stdio.h> int main(void) { int dd,mm,yy,i,leap=0,ordi=0,odd_years,month_days= 0,total ; char week[7][10
STRUTS 2 Could not find action or result
STRUTS 2 Could not find action or result  hiii..i am new to struts 2... on my log: WARNING: Could not find action or result There is no Action... java.sql.Connection; import java.sql.DriverManager; public class ConnectionProvider
return 0 vs exit 0
return 0 vs exit 0  what is the difference between return 0 and exit 0 in c? i could not find any difference in their behaviour (both terminates the process execution) in a program
applicationDidEnterBackground Exit
applicationDidEnterBackground Exit  Hi, Provide me full code of applicationDidEnterBackground exit(0). Thanks   Hi, Here is the complete.... */ exit(0); return; } Thanks
main function defnition in class - Java Beginners
main function defnition in class  why do we use public infront of a main function   Hi friend, The main method is similar to the main... and will subsequently invoke all the other methods required by your program. The main method
write a programm using java
write a programm using java  print the following using java programming
Class and interface in same file and accessing the class from a main class in different package
Class and interface in same file and accessing the class from a main class... a class named CantFly in same file. A main method CheckAnimal.java. Below... class CheckAnimals { public static void main(String[] args) { Animal
Class and interface in same file and accessing the class from a main class in different package
Class and interface in same file and accessing the class from a main class... a class named CantFly in same file. A main method CheckAnimal.java. Below... class CheckAnimals { public static void main(String[] args) { Animal
menu drive programm in java
menu drive programm in java  calculate area of circle, square,rectangele in menu driven programme in java
menu drive programm in java
menu drive programm in java  calculate area of circle, square,rectangele in menu driven programme in java
looping programm of sum
looping programm of sum  s=1+2/12+1+2+3/12*3+1+2+3+..... n
Find Month name using DateFormatSymbols class.
Find Month name using DateFormatSymbols class. In this tutorial, you will learn how to find the month name using DateFormatSymbols class. The class... DateFormat and SimpleDateFormar use DateFormatSymbols class to encapsulate
top 20 basic programm of java
top 20 basic programm of java  what is the top 20 rule to learn the basic of java.   Learn Java through the following links: http://www.roseindia.net/java/ http://www.roseindia.net/java/beginners/index.shtml
NoClassDefFoundError: Could not initialize class com.net.plugin.HibernatePlugIn - Struts
NoClassDefFoundError: Could not initialize class com.net.plugin.HibernatePlugIn  Could not initialize class com.net.plugin.HibernatePlugIn... But its giving error such like NoClassDefFoundError: Could not initialize class
construction in java programm
construction in java programm  p*(1+r/100) at the end of year 200 p is population r is growth rate class name: population Data members : float p,r Member methods: population (int a, int b):Constructor to initialize p and r
cannot find symbol class array queue--plzz somebody help..
cannot find symbol class array queue--plzz somebody help..  import java.util.*; public class Test { public static void main(String[] args) { ArrayQueue<String> q = new ArrayQueue<String>(6); System.out.println
how to write a programm in C for included code below
how to write a programm in C for included code below  Here is my question 'how to write a program in C that runs your sql-xml application session... terminated with a ";" Enter ".quit" to exit sql-xml> cancelled orders
how to pass variable from simple java main class(not servlet) to the jsp page?
how to pass variable from simple java main class(not servlet) to the jsp page?  I have a simple Java class in which I invoke a call to a JSP page... from the simple Java class to the JSP page. How can I do that? Here is my
java programm
format of the input data ?? the program writes an error message to the standard
Change JPanel background color from mouse entered/exit event
Change JPanel background color from mouse entered/exit event  I have a JPanel with a grid layout and I populated it with anonymous JPanels... JPanels to see if I could make it work as a test to just System.out.println("test
Interface Vs Abstract Class
Interface Vs Abstract Class       There are three main differences between an interface and an abstract class: At the same time multiple interfaces can be implemented, but only
could someone help in this ........
could someone help in this ........  dear Sir/Mrs I'll be thankful for helping me on this ....... write a program that reads 10 numbers. find the largest number and count the occurrence of the largest number from a declared
main method
is a class method. void- It indicates that the main() method has no return value...main method  psvm(String args[]) what does this arguement in paranthesis denote?   Hi Friend, public-It indicates that the main() method
J2ME Command Class
J2ME Command Class       In the given J2ME Command Class example, we have set the various...;exit and item to the Midlet. And also set the priority for it such as 1, 2
Can a main method be overloaded?
Can a main method be overloaded?   Hi, Can a main method be overloaded? thanks,   Hi, Yes, In Java program we could having multiple number of main() methods with different Signature and implementation in the class
main method
main method  Why is the java main method static
main method
main method  What is the argument type of a program's main() method