Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

calling a function from a project

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How can a java project calls a function from other java project.
i.e. x , y are two different java projects(not packages). Y has "a" method. X needs that function. How can x calls y's "a" method.
Please help me.

Thanks
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure, but I think you're asking how to call a method from another class (or instance).

If the method is static, then you can call it using the class name. For example, if class SomeClass contains a static method called staticMethod, then you simply call SomeClass.staticMethod().

If the method is not static, then you need a reference to some instance of the class. For example, if class SomeClass contains a non-static method called nonStaticMethod, then you need an instance of SomeClass. Suppose the variable someInstance references such an instance. Then you would call someInstance.nonStaticMethod().
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no such thing as a java "project". Do you mean project in the sense of an IDE, such as Eclipse? If so you can make one Eclipse project depend on another.

Or are you asking about programs residing in different JVMs?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!