1

I was wondering ... I want to use a plugin-type thing with my Java program.

Here is the situation:

I have compiled a source file (.java) into a .jar file using MY .JAR program as a library. How to I make MY program run the other .jar file internally (using the main program as a reference).

I know this is weird (it sounds weird to me too), but if anyone understands what I am trying to say, please comment.

Thank you all in advance!

UmNyobe
  • 22,539
  • 9
  • 61
  • 90
Dylan Wheeler
  • 6,928
  • 14
  • 56
  • 80
  • You should check http://stackoverflow.com/questions/60764/how-should-i-load-jars-dynamically-at-runtime. What you need is a Class Loader. – Cengiz Can Mar 01 '12 at 02:03
  • Does anyone know of the RuneScape botting software? If so, my idea is very similar to the script idea for the software. Does this help? – Dylan Wheeler Mar 01 '12 at 02:12

2 Answers2

2

OK, here's a draft of how to do it.

  • Create an interface with a "run()" method.
  • Your .java plugin must implement that interface.
  • Load the all classes in classpath (help here Find Java classes implementing an interface)
  • run your plugin by executing the run method of the interface.
Community
  • 1
  • 1
Carlos Quijano
  • 1,566
  • 15
  • 23
0

You would have to run the jar using the standard syntax. Your question is basically about running console commands inside java. Here is a nice answer to a similar question: link!
This isn't necessarily exactly what you want, but it's goal is to put you on the right track, basically you would get the jar placement, then check for the system, then use the technique used there to run a command through the specific platform's console.