CrazyEngineers
  • problem in java

    accoolaryan

    Member

    Updated: Oct 25, 2024
    Views: 924
    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?
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Gurjeet Singh

    MemberDec 10, 2009

    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 😀
    Are you sure? This action cannot be undone.
    Cancel
  • sarveshgupta

    MemberDec 10, 2009

    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.*;
    Are you sure? This action cannot be undone.
    Cancel
  • rengaraj

    MemberDec 10, 2009

    Dear accoolaryan,
    I hope this is not the correct location to post your question.
    You can post under Computer Science & IT
    R.Rengaraj
    Are you sure? This action cannot be undone.
    Cancel
  • accoolaryan

    MemberDec 10, 2009

    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?
    Are you sure? This action cannot be undone.
    Cancel
  • itchap

    MemberDec 11, 2009

    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");
    }
    }
    Are you sure? This action cannot be undone.
    Cancel
  • sookie

    MemberDec 11, 2009

    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 <full path of your Java Program>.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 <path where your .class file exists> <Java Program Name>

    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
    Are you sure? This action cannot be undone.
    Cancel
  • accoolaryan

    MemberDec 11, 2009

    Tthanks its working now..
    Are you sure? This action cannot be undone.
    Cancel
  • omeshkalra

    MemberJan 18, 2010

    qns2:-
    pblm in java

    [FONT=&quot]Problem Description:[/FONT]
    [FONT=&quot]Using the steps for Problem Solving - generate for the following problem:[/FONT]
    [FONT=&quot] a) an algorithm AND [/FONT]
    [FONT=&quot] b) PDL AND [/FONT]
    [FONT=&quot] c) test plan AND[/FONT]
    [FONT=&quot] d) write and test the program code in Java.[/FONT]
    [FONT=&quot] [/FONT]
    ·[FONT=&quot] [/FONT][FONT=&quot]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=&quot] [/FONT][FONT=&quot]We will use this problem for many assignments and will build functionality as we progress. [/FONT]
    ·[FONT=&quot] [/FONT][FONT=&quot]For now, the invoice will only handle one roof replaced at a time. [/FONT]
    ·[FONT=&quot] [/FONT][FONT=&quot]The program should ask for the number of hours the job will take.[/FONT]
    ·[FONT=&quot] [/FONT][FONT=&quot]The program should calculate the Invoice Amount – which will be number of hours input above multiplied by $75.00 per hour.[/FONT]
    ·[FONT=&quot] [/FONT][FONT=&quot]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=&quot] [/FONT][FONT=&quot]The program should then ask for payment amount from the user and then calculate and display the change amount to be returned.[/FONT]
    ·[FONT=&quot] [/FONT][FONT=&quot]You do not need to worry about formatting the output - ie numbers to two decimal places, etc. YET....that will come later.[/FONT]
    [FONT=&quot] [/FONT]
    [FONT=&quot]Sample Output #1:[/FONT][FONT=&quot] (italics indicate user entered information)[/FONT]
    [FONT=&quot] [/FONT][FONT=&quot]Please enter number of hours: 10[/FONT]
    [FONT=&quot] Invoice Amount : $ 750.00[/FONT]
    [FONT=&quot] Sales Tax: $ 105.00[/FONT]
    [FONT=&quot] Total Due: $ 855.00[/FONT]
    [FONT=&quot] [/FONT]
    [FONT=&quot] Enter amount paid by customer: 900.00[/FONT]
    [FONT=&quot] Change due: $ 45.00[/FONT]
    [FONT=&quot] [/FONT]
    [FONT=&quot]Sample Output #2:[/FONT][FONT=&quot] (italics indicate user entered information)[/FONT]
    [FONT=&quot] [/FONT][FONT=&quot]Please enter number of hours: 20[/FONT]
    [FONT=&quot] Invoice Amount : $ 1500.00[/FONT]
    [FONT=&quot] Sales Tax: $ 210.00[/FONT]
    [FONT=&quot] Total Due: $ 1710.00[/FONT]
    [FONT=&quot] [/FONT]
    [FONT=&quot] Enter amount paid by customer: 1710.00[/FONT]
    [FONT=&quot] Change due: $ 0[/FONT]
    [FONT=&quot] if anyone can solve this pblm then plse tell me its coding[/FONT]
    [FONT=&quot]thx in advance
    [/FONT]
    Are you sure? This action cannot be undone.
    Cancel
  • Kaustubh Katdare

    AdministratorJan 18, 2010

    Have you tried solving it on your own? If yes, please share your efforts with us.
    Are you sure? This action cannot be undone.
    Cancel
  • sookie

    MemberJan 22, 2010

    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. 😀
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register