problem in java

hello everyone
i got a problem in java
whenever i compiles any java program it gets compiled correctly,
but while running it it gives an error "java.lang.noclassdeffounderror"
why it happens?
i set the classpath of bin directory and made my working directory where my .java file is saved still its not working why?

Replies

  • Gurjeet Singh
    Gurjeet Singh
    check your program that with which name you save the file and run it with different class file name? may be you have made the main class with different name so try to run it with main class name 😀
  • sarveshgupta
    sarveshgupta
    yes aryan the solution given by cooldudeit may help or else you can also try importing lang package in the program by writing

    import java.lang.*;
  • rengaraj
    rengaraj
    Dear accoolaryan,
    I hope this is not the correct location to post your question.
    You can post under Computer Science & IT
    R.Rengaraj
  • accoolaryan
    accoolaryan
    hi everyone
    actually i wrote a simple program
    which was
    public class Me{
    public ststic void main(String []arg){
    System.out.println("COOLARYAN");
    }
    }
    still this program is not working i save it as Me.java. it gets compiled but does not run?
  • itchap
    itchap
    Check out the spelling of static....i have just correct it and its working now.

    public class Me{
    public static void main(String []arg){
    System.out.println("COOLARYAN");
    }
    }
  • sookie
    sookie
    accoolaryan
    hello everyone
    i got a problem in java
    whenever i compiles any java program it gets compiled correctly,
    but while running it it gives an error "java.lang.noclassdeffounderror"
    why it happens?
    i set the classpath of bin directory and made my working directory where my .java file is saved still its not working why?
    You get "NoClassDefFoundError" when JVM doesn't get the .class file of your program. There is no need of setting any classpath.

    Simple way, is keep your program at any location in your system then to simply compile the program
    Go to "bin" directory" of installed directory and enter
    "javac .java

    Now this will by default will generate the .class file at the same location where your Java program resides.

    Now for running the program, same go to "bin" directory of installed Java and enter
    "java -classpath

    Hope it helps ! For more description - you can check this #-Link-Snipped-#

    @sarvesh importing "java.lang" is not at all going to help. 😀

    If still the problem remains, revert back.

    -Sookie
  • accoolaryan
    accoolaryan
    Tthanks its working now..
  • omeshkalra
    omeshkalra
    qns2:-
    pblm in java

    [FONT="]Problem Description:[/FONT]
    [FONT="]Using the steps for Problem Solving - generate for the following problem:[/FONT]
    [FONT="] a) an algorithm AND [/FONT]
    [FONT="] b) PDL AND [/FONT]
    [FONT="] c) test plan AND[/FONT]
    [FONT="] d) write and test the program code in Java.[/FONT]
    [FONT="] [/FONT]
    ·[FONT="] [/FONT][FONT="]This problem will simulate producing a very basic invoice for a Roofing company (ie a company that replaces a roof on a building). [/FONT]
    ·[FONT="] [/FONT][FONT="]We will use this problem for many assignments and will build functionality as we progress. [/FONT]
    ·[FONT="] [/FONT][FONT="]For now, the invoice will only handle one roof replaced at a time. [/FONT]
    ·[FONT="] [/FONT][FONT="]The program should ask for the number of hours the job will take.[/FONT]
    ·[FONT="] [/FONT][FONT="]The program should calculate the Invoice Amount – which will be number of hours input above multiplied by $75.00 per hour.[/FONT]
    ·[FONT="] [/FONT][FONT="]The program should calculate and display the Sales Tax (14% of the Invoice Amount) and the total amount due (ie Invoice Amount + Sales Tax). [/FONT]
    ·[FONT="] [/FONT][FONT="]The program should then ask for payment amount from the user and then calculate and display the change amount to be returned.[/FONT]
    ·[FONT="] [/FONT][FONT="]You do not need to worry about formatting the output - ie numbers to two decimal places, etc. YET....that will come later.[/FONT]
    [FONT="] [/FONT]
    [FONT="]Sample Output #1:[/FONT][FONT="] (italics indicate user entered information)[/FONT]
    [FONT="] [/FONT][FONT="]Please enter number of hours: 10[/FONT]
    [FONT="] Invoice Amount : $ 750.00[/FONT]
    [FONT="] Sales Tax: $ 105.00[/FONT]
    [FONT="] Total Due: $ 855.00[/FONT]
    [FONT="] [/FONT]
    [FONT="] Enter amount paid by customer: 900.00[/FONT]
    [FONT="] Change due: $ 45.00[/FONT]
    [FONT="] [/FONT]
    [FONT="]Sample Output #2:[/FONT][FONT="] (italics indicate user entered information)[/FONT]
    [FONT="] [/FONT][FONT="]Please enter number of hours: 20[/FONT]
    [FONT="] Invoice Amount : $ 1500.00[/FONT]
    [FONT="] Sales Tax: $ 210.00[/FONT]
    [FONT="] Total Due: $ 1710.00[/FONT]
    [FONT="] [/FONT]
    [FONT="] Enter amount paid by customer: 1710.00[/FONT]
    [FONT="] Change due: $ 0[/FONT]
    [FONT="] if anyone can solve this pblm then plse tell me its coding[/FONT]
    [FONT="]thx in advance
    [/FONT]
  • Kaustubh Katdare
    Kaustubh Katdare
    Have you tried solving it on your own? If yes, please share your efforts with us.
  • sookie
    sookie
    Hi omeshkalra,

    Just giving a hint, rest of the part I am sure you can do,

    STEP 1: Create a class "Roofing Company" in which you will be calling "Roof" objects for replacing or whateevr job being done with them.

    STEP 2: Create a class "Roof" with following as its members
    a) Job_Hours
    c) Payment Amount
    b) calInvoice_Amt
    c) calSalesTax
    etc.. etc. amount based on your requirements

    STEP 3: Call Roof object, passing no.of hours and Payment Amount as parameter to that object. Inside it , do your calculations and store the calculated values in appropriate member variables

    STEP 4: Return any values from Roof object to your "Roffing Company" class and do whatever formatting or displaying you want to do with it then.

    Hope it helps. Feel free to ask any questions or adding any better solutions. 😀

You are reading an archived discussion.

Related Posts

Hello to all, This is my first day here and it seems to be a good engineering place... I am engineer of Computer & Telecommunications and now I have registered...
Google launched its amazing browser for Mac and Linux Watch the video [youtube][/youtube] Along with this...
hey can any one tell me how to do MS in INDIA.? i am not able to decide whether to do mtech or ms? aneone who are done with their...
[FONT="]Kurukshetra[FONT="], the annual technical festival of the College of Engineering, Guindy, Anna University, Chennai takes a pan-Indian avatar with this edition of XCEED – a pre-Kurukshetra Robotics event. With the...
I am doing a project at Schneider Electric,Pl let me know about Testing Rigs..PL inform me about various testing rigs available