Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Importing a Java Class to a program

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I have a question here which I really have no idea on how to deal with it. Hopefully it does belong here and not to the Beginner forum...

The situation is like this, I have (or is going to have) a program A that is going to generate another program B. I wish to allow the user of my program A, to specify a Java .class file which is to be imported into the generated program B. The only requirement of the imported Java .class file is that it has a specified function that is required for program B. This check is supposed to be made by program A.

Is this possible? And if it is, could I have some brief guide on how to do it? THanks. Cheers...

(^-^)
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. You've got the loadClass(String name) method available in java.lang.ClassLoader. Once you've loaded it you can interrogate it for your method - look at the methods available in java.lang.Class.
 
reply
    Bookmark Topic Watch Topic
  • New Topic