I have a C# class library that is running a jarFile
string args="java -jar jar.jar...";
ProcessStartInfo startInfo = new ProcessStartInfo("java.exe", args);
Process runProc = Process.Start(startInfo);
But when using the dll from application I found that I must place the jar file in the application’s working directory or to specify full path.
I don’t like both of the option- absulote path is bad, and asking user to copy a jar file to his working directory in order to use the dll is not comfortable.
Is there is some alternative, some way of embedding the jar file to the class library?
You can add the jar file to your project and in the file properties set it to
contentandCopy if newer.This will copy it to the output folder during compilation and ensure it is distributed with the application.
An alternative is to embed the file as a resource – this makes it part of the application executable and let you access it within the application. In order to execute it separately, however, you will need to extract it and save to a file.