Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (408)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Running and communicating with exe files from Java.  (Read 1580 times)
0 Members and 1 Guest are viewing this topic.
Offline zappsweden

Junior Member




Java games rock!


« Posted 2007-05-24 16:44:26 »

I want to be able to start a windows exe from my Java and also communicate with. Say I send it some parameter and also when that exe is done to get its return value.

Runtime().getRuntime().exec

is that the way? How about the parameter passing between the exe and my Java game?
Offline zappsweden

Junior Member




Java games rock!


« Reply #1 - Posted 2007-05-24 18:43:54 »

Bah!
Was kind of easy   Grin

Process process=Runtime.getRuntime().exec("blablabla.exe");

      int i=process.waitFor();
Online Riven
« League of Dukes »

JGO Overlord


Medals: 439
Projects: 4


Hand over your head.


« Reply #2 - Posted 2007-05-24 20:48:11 »

Be sure to handle the I/O of the process, of it might hang suddenly (outputbuffer full)

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Projects: Revenge of the Titans, Titan Attacks, Droid Assault, and Ultratron
Games published by our own members! Check 'em out!
Try the Free Demo of Droid Assault
Offline zappsweden

Junior Member




Java games rock!


« Reply #3 - Posted 2007-06-07 19:02:24 »

It was easy starting an exe and getting return value. But now I want also to send parameters to it, alternatively start the exe with a parameter.

So, I tried.

Process process=Runtime.getRuntime().exec(Global.getInstallPath()+"myfile.exe");
     BufferedOutputStream bos = new BufferedOutputStream(process.getOutputStream());
bos.write(123456);


It seems the exe never receive those numbers and I do not know why...

Online Riven
« League of Dukes »

JGO Overlord


Medals: 439
Projects: 4


Hand over your head.


« Reply #4 - Posted 2007-06-07 19:59:43 »

flush

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Projects: Revenge of the Titans, Titan Attacks, Droid Assault, and Ultratron
Offline zappsweden

Junior Member




Java games rock!


« Reply #5 - Posted 2007-06-08 00:08:31 »

flush

I tried 2 ways:

i)
bos.write(123456);
bos.flush();


ii)
bos.write(123456);
process.getOutputStream().flush();


neither worked
Offline cylab

JGO Knight


Medals: 30



« Reply #6 - Posted 2007-06-08 00:32:36 »

are you sure you are reading the data correct in the started exe?

Mathias - I Know What [you] Did Last Summer!
Offline zappsweden

Junior Member




Java games rock!


« Reply #7 - Posted 2007-06-08 00:34:01 »

are you sure you are reading the data correct in the started exe?

No, I did not make the exe myself. So, my code looks ok then? I should be talking to the guy who made that exe then.
Offline keldon85

Senior Member


Medals: 1



« Reply #8 - Posted 2007-06-08 01:38:29 »

No, I did not make the exe myself. So, my code looks ok then? I should be talking to the guy who made that exe then.


 Wink

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (121 views)
2013-05-17 21:29:12

alaslipknot (129 views)
2013-05-16 21:24:48

gouessej (159 views)
2013-05-16 00:53:38

gouessej (151 views)
2013-05-16 00:17:58

theagentd (164 views)
2013-05-15 15:01:13

theagentd (149 views)
2013-05-15 15:00:54

StreetDoggy (193 views)
2013-05-14 15:56:26

kutucuk (217 views)
2013-05-12 17:10:36

kutucuk (216 views)
2013-05-12 15:36:09

UnluckyDevil (219 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.085 seconds with 21 queries.