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

November 3rd, 2013, 12:25 PM

GregBrannon

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.

November 3rd, 2013, 12:44 PM

thedarkhitman

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?

November 3rd, 2013, 12:52 PM

GregBrannon

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.

November 3rd, 2013, 05:28 PM

thedarkhitman

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.