I'm quite a java newbie, writing applets for the first time. I will be writing a file parser which gets the name and location of a class file. Given this information, is it possible to call methods which are stored in the external class file?
First, a bit of business: you may not have read our naming policy on the way in. It requires that you use a full, real (sounding) first and last name for your display name. You can change your display name here. Thanks!
Now, as to your question: yes, you can do this. You want to learn about "reflection".
Note that applets (the web-page kind) have numerous security restrictions placed on them, and accessing files on the local machine is one of the prohibitions. You may want to consider writing your code as a standalone application, at least at the beginning, as you're learning, to sidestep this problem.
cheers for the fast reply and info! exactly what I needed to know thanks If I have any more trouble after learning, I'll post some more in this thread
posted 14 years ago
I have a question about the reflection API, the tutorial says: "The reflection API represents, or reflects, the classes, interfaces, and objects in the current Java Virtual Machine" How can I load an external class file into the current JVM?