开发者

Running Java Application in C# NET

开发者 https://www.devze.com 2023-02-14 15:55 出处:网络
I wrote an application a while ago in C# NET that basically allows the .exe I created to start/stop when the java application (Minecraft) starts and stops.

I wrote an application a while ago in C# NET that basically allows the .exe I created to start/stop when the java application (Minecraft) starts and stops.

I would like to extend some more functionality to my application by basically allowing users to type commands into my console app, and in turn send these commands to the .jar file that is running.

I read something a while开发者_如何学编程 ago on stackoverflow that said there were some APIs that would basically let you manage Java apps inside of a C# NET app but I can't find it now.

Does anyone know how I could go about doing this?


If you launch and manage the java app from C# using the Process class, you can send input from your C# app to the launched java app process via Process.StandardInput.


Minecraft accepts commands from system in and responds to system out.

When you start minecraft from your application you basicly creates a new process. This process has two streams, one for system out and one for system in. You need to get hold of those streams. If you send characters to the system in stream, then they will be interpreted as commands to minecraft. If you read from the system out stream then you will get minecrafts response.

Your next task would be to let your users send commands to minecraft. One way to do this would be to let your users type in commands on a web page that you store in a file. You could have a separate thread read from the file and write the commands to minecraft's system in stream.

0

精彩评论

暂无评论...
验证码 换一张
取 消