• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how do I use methods in external class file?

 
David Llewellyn
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Cheers
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mr. Elephant,

Welcome to JavaRanch!

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.
 
David Llewellyn
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ernest, I changed my name as required

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

cheers!
 
David Llewellyn
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Joe Ess
Bartender
Posts: 9340
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With a ClassLoader
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic