You are not logged in.

scGuy

Beginner

  • "scGuy" started this thread

Posts: 40

Date of registration: Jan 12th 2011

  • Send private message

1

Wednesday, January 26th 2011, 7:50pm

Accessing external java classes

...and not being a Java programmer, I have no idea if that makes sense, but here's what I'm taking about.

In VB6, I routinely use CreateObject to create activex objects on the fly that the calling application has no knowledge of--no references, no links of any kind. If the object isn't available on the machine, CreateObject errors, otherwise I have an activex object I can use.

Now, I don't care about activex--here's my question: Assuming I have some java class implemented in an external .jar file, and the calling jabaco app has no knowledge of it, then: What statements can I use to instantiate and use a class out of this external .jar?

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

2

Wednesday, January 26th 2011, 8:16pm

Open the ClassBrowser (for example by pressing [F1]) and then adding a jar-file. After that, choosing in the Classbrowser your Class file in the jar or write with the command "Import" in the IDE, which class you want to import.

scGuy

Beginner

  • "scGuy" started this thread

Posts: 40

Date of registration: Jan 12th 2011

  • Send private message

3

Thursday, January 27th 2011, 4:44am

You have described how it would be done through the IDE, when the references are known. Imagine writing an application where you prompted the user for a class name, and then instantiated that class based on the name alone. Is this possible in Java?

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

4

Thursday, January 27th 2011, 11:01am

It is possible in Java. Ask Google for "Java Reflection" or look here.

Greetings

A1880

Rate this thread
WoltLab Burning Board