1

Me and a friend have being trying to do this for a while and regardless of how hard we searched and tried; we just couldn't do it.

But what we are trying to do is Run/Execute a .jar file from delphi ( from like a click of a button )

I did try using ShellExecute (from the ShellAPI) but I didn't how to pass the parameters correctly;

The end purpose we want it to execute his minecraft server (bukkit) with delphi; (These are the usual parameters that are passed "java -Xmx1024M -Xms1024M -jar minecraft_server.jar") It may seem pointless, but we thought it would be a good challenge and I'm not one for giving up! So I was wondering is it possible with out using outside libraries and could you help me? I'm not asking for a source I'm asking for assistance and a starting point. Thanks in advance

JeremehD
  • 23
  • 3
  • 7
  • http://stackoverflow.com/questions/394616/running-jar-file-in-windows – Jan Doggen May 20 '13 at 19:01
  • @JanDoggen thanks for the reply; but that didn't really do anything for me; I know how to run one through CMD but I am trying to recreate that in delphi and i was wondering if there is a way – JeremehD May 20 '13 at 19:22
  • Jeremehd, to run a jar file from Delphi, you simply take the answer for how to run a jar file *in general* (which Jan linked to), and combine it with the answer to how to run *anything* in Delphi (which you can certainly find for yourself). – Rob Kennedy May 20 '13 at 19:34
  • @RobKennedy Oh so i could use the ShellAPI? if i just pass the parameters correctly? – JeremehD May 20 '13 at 19:38

1 Answers1

4

Like this:

ShellExecute(
    0, 
    nil, 
    'java.exe', 
    '-Xmx1024M -Xms1024M -jar minecraft_server.jar',
    nil,
    SW_SHOW
);

In order for this to work, the file minecraft_server.jar must be located in the working directory when you call ShellExecute. If you cannot ensure that then pass the full path to the .jar file.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490