Results 1 to 13 of 13
  1. #1
    Gousia is offline Member
    Join Date
    Feb 2011
    Posts
    38
    Rep Power
    0

    Default Can't See the output

    I have wrote my program on Notepad++.

    Now when i am trying to compile my program through command prompt it is compiling but when i am trying to run the program i am not getting any output while the notepad on which i have wrote the program is getting displayed

    Please help me out what is the problem

  2. #2
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    How would we know unless you show us what have you written?

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  3. #3
    Gousia is offline Member
    Join Date
    Feb 2011
    Posts
    38
    Rep Power
    0

    Default

    This is the code i have written

    //Demonstrate Method Overloading.
    class OverloadDemo
    {
    void test()
    {
    System.out.println("No parameters");
    }

    //Overload test for one integer parameter.
    void test(int a)
    {
    System.out.println("a: " + a);
    }

    //Overload test for two integer parameters.
    void test(int a,int b)
    {
    System.out.println("a and b: " + a + " " + b);
    }

    //Overload test for double parameter
    double test(double a)
    {
    System.out.println("double a:" + a);
    return a * a;
    }
    }


    class Overload
    {
    public static void main(String args[])
    {
    OverloadDemo ob = new OverloadDemo();
    double result;

    //call all versions of test()
    ob.test();
    ob.test(10);
    ob.test(10,20);

    result = ob.test(123.2);
    System.out.println(result);


    }

    }

  4. #4
    Gousia is offline Member
    Join Date
    Feb 2011
    Posts
    38
    Rep Power
    0

    Default

    Now when i am compiling this program it's showing no errors,but while running the notepad containing the code is getting displayed

  5. #5
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    Well, your code ran fine with me.

    What are the command line arguments you are using to compile and run this?

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  6. #6
    Gousia is offline Member
    Join Date
    Feb 2011
    Posts
    38
    Rep Power
    0

    Default

    To compile i am using

    javac <programname>.java

    and to run

    <programname.java

  7. #7
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    You should use,

    To Compile: javac Overload.java

    To Run: java Overload

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  8. #8
    Gousia is offline Member
    Join Date
    Feb 2011
    Posts
    38
    Rep Power
    0

    Default

    But the name of my class is OverloadDemo so i have saved it wiith the same name

    Now if i tried to execute it as you specified it's throwing an error of file not found

  9. #9
    Gousia is offline Member
    Join Date
    Feb 2011
    Posts
    38
    Rep Power
    0

    Default

    I think i have to save it with the class name that contains main method-- Is it

  10. #10
    Gousia is offline Member
    Join Date
    Feb 2011
    Posts
    38
    Rep Power
    0

    Default

    But still its showing the same notepad

  11. #11
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    Yeah. You are supposed to run the java file that contains the main method. In your case it is, Overload.java

    If you try to use java command on file with no main method, there will be error saying, "NoSuchMethodError: main"

    I hope you are clear with that,

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  12. #12
    Gousia is offline Member
    Join Date
    Feb 2011
    Posts
    38
    Rep Power
    0

    Default

    Got it

    I was doing a mistake
    For running i was using Overload java
    now by java Overload it worked fine


    Thanks a lot for your help,,thanks

  13. #13
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    You are Welcome. :D

    Go through this simple tutorial which will help you understand the things in much clear way : Hello World

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

Similar Threads

  1. Replies: 0
    Last Post: 09-30-2010, 08:16 PM
  2. Why do I get this output?
    By Allspark in forum New To Java
    Replies: 3
    Last Post: 09-23-2010, 08:07 AM
  3. Can anyone tell me how this output?
    By vysh in forum Advanced Java
    Replies: 16
    Last Post: 05-10-2009, 08:32 PM
  4. Java, output string, getting correct output? HELP!
    By computerboyo in forum New To Java
    Replies: 2
    Last Post: 02-25-2009, 11:44 PM
  5. how to c the output
    By pro85 in forum Java Applets
    Replies: 1
    Last Post: 02-11-2009, 09:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •