Communication stdin / stdout between Java program and C program under 64-bit windows 7

I have a C program that is generated from a Java program. The C program is mine, and the Java program is third-party. The Java program somehow installs everything so that it communicates with my program via stdin / stdout.

For many years, the system has been running 32-bit Windows XP. I just bought a new machine with 64-bit Windows 7. When I started the Java program (from the dos window), it successfully completed my program and sent my program a command with which my program successfully worked. But when my program returned to its loop with

inputchar = getc(stdin);

getc (stdin) never returns.

Key: I know almost nothing about Java, and I had problems launching it in the first place. It seemed that after installing it from java.com, if I went to the "dos" field and typed "java", I received an unrecognized command error. Then I found java.exe on windows \ sysWOW64, so I typed "windows \ sysWOW64 java -jar blah blah ..." and then the program looked like it was working (at least until the getc (stdin) problem).

Any idea what could go wrong? Do I need special 64-bit Windows-7 Java? Is it possible that its just a poorly written Java program that detects errors only when working on a new OS? Or most likely I will?

EDIT: my C program is working fine (i.e. not spawned from java) on a 64 bit Windows 7 machine.

EDIT: "\ windows\syswow64\java -version", ...

java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing)

EDIT: XP java 1.6.0_17-b04

EDIT: C . 32- .

EDIT: "", java, - , "line feed" (ASCII 10).

+3
3

Java C-? , - :

Process cPgm = Runtime.exec("your-C-program");
OutputStream stdin = cPgm.getOutputStream();
stdin.write("some-command".getBytes());
stdin.flush();
cPgm.waitFor();

, , . cPgm.destroy(), , . , , .

64- ? , JRE "WOW64", , - (WOW , DOS, "Windows Windows" ). , - , , .

+2

, 64- .

  • 64- Java. 32- , java.exe Windows "Windows Windows" ( 32- . 32- ( c:\windows\syswow64\cmd.exe), , java.exe , . 64- Java, 64- -bit ( ), .

    java -version java- "1.6.0_17" Java (TM) SE Runtime Environment ( 1.6.0_17-b04) Java HotSpot (TM) 64- VM ( 14.3-b01, )

  • 32- C 32- 64- Java- ( ). , , , , , , . C, , getc (stdin) , ? , getc Windows 7 XP, .

0

? , ( " " ).

Windows Vista 7 โ€‹โ€‹ UAC, , , , , Java Java.

0
source

Source: https://habr.com/ru/post/1731070/


All Articles