How to execute a Java program from C#?
If you need finer control than launching an external program, then consider IKVM - http://www.ikvm.net/ - which provides a way to run Java programs inside a .NET world.
What are some ways to compile Java from C# code?
You do have other options. Java provides JNI (Java Native Interface ) which allows Java to call native code and apropos, for native code to call Java (albeit in a rather complex way.)
Depending on how much of a learning experience you want this to be you can use JNI directly or use a library such as jni4net. A different interop approach is to use ikvm which is a jvm running inside the clr, but I don't think it'll be useful to you as it does not include a compiler.
You can also research alternative compilers such as gcj or ejc.
Not having tried to write an IDE I don't know whether these approaches are actually better than using the command line directly. My hunch is that for simple integration the command line is the easier to use however more complex scenarios, e.g. incremental compilation of large projects with multiple components, may require tighter integration.
If you plan on providing features such as inline debugging and error highlighting while you type you're going to require tighter integration anyway.
IDEs are extremely complex programs, even mere programming editors are complex enough.
How to execute a Java app with arguments in c#
You need to put spaces in the strings you're concatenating, your command currently looks like
java -jar javaapp.jarhost:portpassword/saytest
The simplest way is to use string.Format
:
string command1 = "/say"
string command2 = "test"
string args = string.Format("-jar javaapp.jar {0}:{1} {2} {3} {4}", host, port, password, command1, command2);
startInfo.Arguments = args;
Running Java Application in C# NET
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.
How to run jar file form C# code
You will have to provide -jar switch to java command.
For example, the command to execute JAR file is,
java -jar D:\\DATA\\PROJECT\\LicensingManagement\\Assignment\\JavaLogin.jar
So you may try,
myProcess.StartInfo.Arguments = "-jar D:\\DATA\\PROJECT\\LicensingManagement\\Assignment\\JavaLogin.jar";
Related Topics
Do I Need to Lock or Mark as Volatile When Accessing a Simple Boolean Flag in C#
C# Gui Refresh and Async Serial Port Communication
Datetime to String with Time Zone
Why Is There Huge Performance Hit in 2048X2048 Versus 2047X2047 Array Multiplication
Learning Single Responsibility Principle with C#
How to Create a C# App That Decides Itself Whether to Show as a Console or Windowed App
ASP.NET MVC: Calling a Method from a View
How Can One Generate and Save a File Client Side Using Blazor
ASP.NET Core Jwt Mapping Role Claims to Claimsidentity
Starting and Stopping Iis Express Programmatically
Wait for an Ajax Call to Complete with Selenium 2 Webdriver
Entity Framework Core Using Multiple Dbcontexts
Dependency Injection - New Instance Required in Several of a Classes Methods
Merge Multiple Word Documents into One Open Xml
Yield Return Statement Inside a Using() { } Block Disposes Before Executing