public static string convertJarFileIntoDotNetAssembly(this API_IKVM ikvm, string pathToJarFile, string targetDirectory)
        {
            if (File.Exists(pathToJarFile) && Path.GetExtension(pathToJarFile) == ".jar")
            {
                var destinationFile = Path.Combine(targetDirectory,
                                                   Path.GetFileNameWithoutExtension(pathToJarFile) + ".dll");
                Files.deleteFile(destinationFile);
                var executionParameters = string.Format(ikvm.IKVMCompilerArgumentsFormat, pathToJarFile,
                                                        destinationFile);
                var executionResult =
                    Processes.startProcessAsConsoleApplicationAndReturnConsoleOutput(ikvm.IKVMCompilerExecutable,
                                                                                     executionParameters);
                if (File.Exists(destinationFile))
                {
                    return(destinationFile);
                }

                "in IKVMUtils.convertJarToDotNetAssembly, Jar file was not Converted into .Net Dll".error();
            }
            else
            {
                "in IKVMUtils.convertJarToDotNetAssembly, only jar files are supported".error();
            }
            return("");
        }
/*        public static API_IKVM install_IKVM_Assemblies_on_GAC(this API_IKVM ikvm)
 *      {
 *              "Installing IKVM dlls in local GAC folder".info();
 *              var gacUtil =  new DotNet_SDK_GacUtil();
 *              foreach(var file in ikvm._IKVMRuntimeDir.files("ikvm*.*"))
 *                      if (file.fileName().neq("ikvm-native.dll") && gacUtil.install(file).isFalse())
 *                      {
 *                              "Failed to install into GAC, so stopping installation process".error();
 *                              break;
 *                      }
 *                      return ikvm;
 *      }
 */
        public static bool checkIfJavaPathIsCorrectlySet(this API_IKVM ikvm)
        {
            var javaHome = Environment.GetEnvironmentVariable("Java_Home");

            if (string.IsNullOrEmpty(javaHome))
            {
                "in checkIfJavaPathIsCorrectlySet, could not find Java_Home variable".error();
            }
            else
            {
                var javaCompiler = Path.Combine(javaHome, @"bin\javac.exe");
                if (!File.Exists(javaCompiler))
                {
                    "in checkIfJavaPathIsCorrectlySet, could not find javaCompiler executable: {0}".error(javaCompiler);
                }
                {
                    var javaParser = Path.Combine(javaHome, @"bin\javap.exe");
                    if (!File.Exists(javaParser))
                    {
                        "in checkIfJavaPathIsCorrectlySet, could not find javaParser executable: {0}".error(javaParser);
                    }
                    else
                    {
                        ikvm.javaCompilerExecutable = javaCompiler;
                        ikvm.javaParserExecutable   = javaParser;

                        return(true);
                    }
                }
            }
            return(false);
        }
 public static void uninstallIKVM(this API_IKVM ikvm)
 {
     if (Directory.Exists(ikvm._IKVMRuntimeDir))
     {
         Files.deleteFolder(ikvm._IKVMRuntimeDir, true);
     }
 }
 private void onLoad()
 {
     if (DesignMode == false && runOnLoad) 
     {
     	ikvm = new API_IKVM();
         loadDefaultSetOfFilesToConvert();
         directoryWithJarStubFiles.openDirectory(ikvm.jarStubsCacheDir);
         directoryToDropJarsToConvertIntoDotNetAssemblies.openDirectory(ikvm.convertedJarsDir);
     }
 }
Exemple #5
0
 private void onLoad()
 {
     if (DesignMode == false && runOnLoad)
     {
         ikvm = new API_IKVM();
         loadDefaultSetOfFilesToConvert();
         directoryWithJarStubFiles.openDirectory(ikvm.jarStubsCacheDir);
         directoryToDropJarsToConvertIntoDotNetAssemblies.openDirectory(ikvm.convertedJarsDir);
     }
 }
 public static bool checkIKVMInstallation(this API_IKVM ikvm)
 {
     Files.checkIfDirectoryExistsAndCreateIfNot(ikvm.jarStubsCacheDir);
     if (ikvm.checkIfJavaPathIsCorrectlySet())
     {
         if (Directory.Exists(ikvm._IKVMRuntimeDir) && File.Exists(ikvm.IKVMCompilerExecutable) && File.Exists(ikvm.IKVMStubExecutable))
         {
             return(true);
         }
     }
     return(false);
 }
        public static API_IKVM install_IKVM_Assemblies_on_GAC(this API_IKVM ikvm)
        {
            "Installing IKVM dlls in local GAC folder".info();
            var gacUtil = new DotNet_SDK_GacUtil();

            foreach (var file in ikvm.IKVMInstallationDir.files("ikvm*.*"))
            {
                if (file.fileName().neq("ikvm-native.dll") && gacUtil.install(file).isFalse())
                {
                    "Failed to install into GAC, so stopping installation process".error();
                    break;
                }
            }
            return(ikvm);
        }
        public static API_IKVM installIKVM(this API_IKVM ikvm)
        {
            var downloadedFile = ikvm.zippedIKVMRunTime.downloadFile();

            if (false == downloadedFile.fileExists())
            {
                "in installIKVM, could not find downloaded file (url was: {0})".error(ikvm.zippedIKVMRunTime);
            }
            else
            {
                "Installing IKVM to: {0}".info(ikvm._IKVMRuntimeDir);
                new zipUtils().unzipFile(downloadedFile, ikvm._IKVMRuntimeDir);
                if (Directory.Exists(ikvm._IKVMRuntimeDir))
                {
                    "IKVM sucessfully installed".info();
                }
                else
                {
                    "Problem installing/unziping _IKVMRuntimeDir: {0}".error(ikvm._IKVMRuntimeDir);
                }
                //JavaShell.testIKVM();
            }
            return(ikvm);
        }
 public JavaExec(API_IKVM _ikvm)        
 {
 	ikvm = _ikvm;
     ikvm.checkIKVMInstallation();
 }
Exemple #10
0
 public JavaShell(API_IKVM _ikvm)
 {
     ikvm = _ikvm;
 }
 public JavaExec(API_IKVM _ikvm)
 {
     ikvm = _ikvm;
     ikvm.checkIKVMInstallation();
 }
Exemple #12
0
 public JavaCompile(API_IKVM _ikvm)
 {
 	ikvm = _ikvm;
     ikvm.checkIfJavaPathIsCorrectlySet();
 }
Exemple #13
0
 public JavaShell(API_IKVM _ikvm)        
 {
 	ikvm = _ikvm;
 }
 public JavaCompile(API_IKVM _ikvm)
 {
     ikvm = _ikvm;
     ikvm.checkIfJavaPathIsCorrectlySet();
 }