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.

Results 1 to 5 of 5

Thread: How to call methods from another class using Eclipse IDE? Please help!

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default How to call methods from another class using Eclipse IDE? Please help!

    Hi everyone,
    I am a newbie to Java and teaching myself how to programme. I am using Eclipse IDE. I am doing a tutorial on Classes and Objects.

    QUESTION: Can somebody kindly please tell me how I can call another class?

    I am doing an exercise from a book that requires me to place a class that has already been written into my project so that my compiler can find it when I do the exercise and call the methods from the pre-written class.

    Please help!


    Many thanks in advance


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: How to call methods from another class using Eclipse IDE? Please help!

    Try reading this to see if it helps. You should refer to these tutorials often as you teach yourself Java.

  3. #3
    Junior Member
    Join Date
    Nov 2013
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: How to call methods from another class using Eclipse IDE? Please help!

    Thanks for your quick reply. I am both new to Java and the forum and still finding my way around here. Many thanks Greg shall check it out now.

    --- Update ---

    I have a new question please, is it better practice to copy and paste the second Class I will be using into my project package or is it better to configure the build classpath and add it as an 'External JAR?'

    It seems both would do the same job but I am not sure which is the best practice?

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: How to call methods from another class using Eclipse IDE? Please help!

    While that link will give you some insight, it may not be all you need. It would be helpful as you study and ask for help on these elemental parts of the language and OOP concepts to create simple little programs to demonstrate what you're learning or hoping to understand better. If they "work," you're all the smarter, but continue to stretch them until they break, and then learn how to fix them. When you can't write them in the first place, or you break them so badly that you can't fix them, then ask for help.

    --- Update ---

    Stick with just adding classes to your own packages for now. External jars are for adding 3rd party libraries that you may need as your skills expand.

  5. The Following User Says Thank You to GregBrannon For This Useful Post:

    thedarkhitman (November 3rd, 2013)

  6. #5
    Junior Member
    Join Date
    Nov 2013
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: How to call methods from another class using Eclipse IDE? Please help!

    That's excellent advice.

    I did as you said, and added classes to packages for now and managed to solve the exercise I was doing.


    I salute you for your time and help. Many thanks!

Similar Threads

  1. Adding maven plugin to Eclipse Ide
    By AMBASHA in forum Java IDEs
    Replies: 0
    Last Post: February 20th, 2013, 02:46 AM
  2. IDE Eclipse Exporting Problem
    By DanielJamesCollier in forum Java IDEs
    Replies: 2
    Last Post: January 2nd, 2013, 06:26 PM
  3. Minimalist GUI, do I need to add anything to Eclipse IDE?
    By cowboytaketwo in forum Java IDEs
    Replies: 1
    Last Post: December 7th, 2011, 02:00 PM
  4. How to Compile JSP in Eclipse (or other IDE)?
    By KevinWorkman in forum JavaServer Pages: JSP & JSTL
    Replies: 8
    Last Post: October 31st, 2011, 12:37 PM
  5. Porting from Processing IDE to Eclipse
    By kafka82 in forum What's Wrong With My Code?
    Replies: 12
    Last Post: June 4th, 2011, 10:18 AM