Skip to content
Advertisement

execute a .jar file from C# but it generates files at wrong location

I have coded a Minecraft Server Runner in C# WinForms which lets you run a Minecraft Server, a .jar file which needs to generate files. The problem is that I launch this .jar file via the .exe application, and the files generate at the .exe application location.

— What I have tried:

I tried moving the .exe application to the specific server file location, but the application needs a restart to register this change which I don’t want to happen.

I also don’t want the user being forced to put the .exe application to the Server folder and restart it. Here is the code I use to launch the .jar file:

JavaScript

How can I fix this issue?

Advertisement

Answer

To fix this I executed the .jar file in the C# application via the CMD. Here is the code I used instead:

JavaScript

All credits go to “Olivier Rogier” ( https://stackoverflow.com/users/12031933/olivier-rogier ) for helping me find this solution

Advertisement