Author Topic: [Java] Loading class files?  (Read 3882 times)

0 Members and 1 Guest are viewing this topic.

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
[Java] Loading class files?
« on: June 16, 2006, 02:16:42 am »
Remember in JavaOp1, how there was a folder of .class files for each packet and they were dynamically loaded on startup? How was that done? I tried reading the code but it was *really* overintwined. =/
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: [Java] Loading class files?
« Reply #1 on: June 16, 2006, 10:18:29 am »
This isn't a tutorial. 

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: [Java] Loading class files?
« Reply #2 on: June 16, 2006, 01:23:17 pm »
Ok, it's in the right forum.  I still don't like how the question was asked, but I'll give you a hint anyways:

Look in the file: javaop/src/commands/util/DocumentFlags.java

All you need to know is in there. 

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: [Java] Loading class files?
« Reply #3 on: June 16, 2006, 07:54:58 pm »
Code: [Select]
RemoteCommandInterface r = (RemoteCommandInterface) Class.forName("commands." + thisFile).newInstance();
So, implement an interface that the bot is aware of, and then use Class.forName(pkgName " + "." + className + ".class").newInstance(); and typecast it back to that interface? Sweet. I was just looking at the packet stuff and forgot about the commands.

PS: Sorry for insulting your coding style with the overintwined comment at the beginning. =p
I'd personally do as Joe suggests

You might be right about that, Joe.