public virtual void javaCompileAndRun()
{
try{
string class_name = java_file_name.Split('.')[0];
File.Delete(JuneConfig.java_files_path + "/" + class_name + ".class");
//ProgramLogger.LogKV("filedeleted", JuneConfig.java_files_path + "/" + class_name + ".class");
Process compile_process = Shell.shell_no_start("javac", "-classpath \"" + JuneConfig.june_files_path + "\" "+JuneConfig.java_files_path+"/"+java_file_name);
compile_process.Start();
var output = compile_process.StandardOutput.ReadToEnd();
var error = compile_process.StandardError.ReadToEnd();
// need to free the resources for the process
compile_process.WaitForExit();
compile_process.Close();
// Popup.mainPopup.popup("" + output + " " + error);
if(!error.Equals(""))
{
success = false;
FileLogger.Log("error launching Java process: "+error);
}
//ProgramLogger.LogKV("compile", getSpellName()+", "+success);
if (!success) {
is_stopped = true;
TraceLogger.LogKV("failedspell", getSpellName());
return;
}
// Process test = Shell.shell_no_start("java", "-version");
// test.Start();
//
// var output2 = test.StandardOutput.ReadToEnd();
// var error2 = test.StandardError.ReadToEnd();
//
// UnityEngine.Debug.Log (output2 + " " + error2);
if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor)
{
UnityEngine.Debug.Log("java " + "-classpath \"" + JuneConfig.june_files_path + ";" + JuneConfig.java_files_path+"\" june.Caster "+class_name+" \"" + object_id +"\"");
java_process = Shell.shell_no_start("java", "-classpath \"" + JuneConfig.june_files_path + ";" + JuneConfig.java_files_path+"\" june.Caster "+class_name+" \"" + object_id +"\"");
}
else
{
UnityEngine.Debug.Log("java " + "-classpath \"" + JuneConfig.june_files_path + ":" + JuneConfig.java_files_path+"\" june.Caster "+class_name+" \"" + object_id +"\"");
java_process = Shell.shell_no_start("java", "-classpath \"" + JuneConfig.june_files_path + ":" + JuneConfig.java_files_path+"\" june.Caster "+class_name+" \"" + object_id +"\"");
}
java_process.Start();
var output3 = java_process.StandardOutput.ReadToEnd();
var error3 = java_process.StandardError.ReadToEnd();
UnityEngine.Debug.Log (output3 + " " + error3);
Boolean has_exited = Convert.ToBoolean(java_process.GetType().GetProperty( "HasExited" ).GetValue(java_process, new object[]{}));
while(!has_exited )
{
if(!isPlaying)
Stop();
//UnityEngine.Debug.Log("Waiting for Java process to exit: ");
Thread.Sleep(500);
has_exited = Convert.ToBoolean(java_process.GetType().GetProperty( "HasExited" ).GetValue(java_process, new object[]{}));
}
if(java_process.ExitCode != 0)
{
success = false;
}
// free resources for this process
java_process.WaitForExit();
java_process.Close();
TraceLogger.LogKV("endspell", getSpellName());
is_stopped = true;
}catch(Exception e){
UnityEngine.Debug.Log(e);
}
}