Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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 2009 times)
0 Members and 1 Guest are viewing this topic.
Offline zappsweden

Junior Duke




Java games rock!


« Posted 2007-05-24 14: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 Duke




Java games rock!


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

Bah!
Was kind of easy   Grin

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

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

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #2 - Posted 2007-05-24 18: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
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline zappsweden

Junior Duke




Java games rock!


« Reply #3 - Posted 2007-06-07 17: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...

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


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

flush

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline zappsweden

Junior Duke




Java games rock!


« Reply #5 - Posted 2007-06-07 22: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 Ninja


Medals: 52



« Reply #6 - Posted 2007-06-07 22: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 Duke




Java games rock!


« Reply #7 - Posted 2007-06-07 22: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 Duke


Medals: 1



« Reply #8 - Posted 2007-06-07 23: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.

 

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

The first screenshot will be displayed as a thumbnail.

Longarmx (37 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (27 views)
2014-10-15 16:18:58

TehJavaDev (52 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (42 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (77 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!