public virtual void Setup() { var sp = new FileIOPermission(PermissionState.Unrestricted); sp.Assert(); string prefix; if (Environment.CurrentDirectory.EndsWith("target")) { prefix = "../../"; } else { prefix = "../../../"; } sp.Deny(); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); BridgeSetup setup=new BridgeSetup (false){Verbose = true, Debug = true}; setup.IgnoreJavaHome = true; setup.AddJVMOption("-Xmx512m"); setup.AddClassPath(prefix + "jni4net.j/target/classes"); setup.AddClassPath(prefix + "jni4net.tested.j/target/classes"); setup.AddClassPath(prefix + "jni4net.test.j/target/test-classes"); //setup.JavaHome = @"c:\Program Files (x86)\Java\ibm_sdk60"; env = Bridge.CreateJVM(setup); Bridge.RegisterAssembly(typeof(TestBase).Assembly); Bridge.RegisterAssembly(typeof(JavaInstanceFields).Assembly); }
public virtual void Setup() { var sp = new FileIOPermission(PermissionState.Unrestricted); sp.Assert(); string prefix; if (Environment.CurrentDirectory.EndsWith("target")) { prefix = "../../"; } else { prefix = "../../../"; } sp.Deny(); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); BridgeSetup setup = new BridgeSetup(false) { Verbose = true, Debug = true }; setup.IgnoreJavaHome = true; setup.AddJVMOption("-Xmx512m"); setup.AddClassPath(prefix + "jni4net.j/target/classes"); setup.AddClassPath(prefix + "jni4net.tested.j/target/classes"); setup.AddClassPath(prefix + "jni4net.test.j/target/test-classes"); //setup.JavaHome = @"c:\Program Files (x86)\Java\ibm_sdk60"; env = Bridge.CreateJVM(setup); Bridge.RegisterAssembly(typeof(TestBase).Assembly); Bridge.RegisterAssembly(typeof(JavaInstanceFields).Assembly); }
private static void Init() { BridgeSetup bridgeSetup = new BridgeSetup(true); bridgeSetup.AddClassPath("."); bridgeSetup.AddClassPath("work"); Bridge.CreateJVM(bridgeSetup); Bridge.RegisterAssembly(typeof(Thread).Assembly); }
/// <summary>Add a list of semicolumn-separated files in the specified directory to the BridgeSetup JVM classpath. /// <para>This is a convenience method which calls <c>BridgeSetup.AddClassPath(dir + "/" + file)</c> for each file in the list</para></summary> /// <param name="setup">the <c>BridgeSetup</c> instance</param> /// <param name="dir">the path of the enclosing directory</param> /// <param name="files">A string containing file names separated by semicolumn characters</param> public static void AddClassPaths(this BridgeSetup setup, string dir, string files) { if ((dir != null) && (files != null)) { foreach (string file in files.Split(';')) { setup.AddClassPath(dir + "/" + file); } } }
/// <summary>Add a list of semicolumn-separated paths to the BridgeSetup JVM classpath. /// <para>This is a convenience method which calls <c>BridgeSetup.AddClassPath(path)</c> for each path in the list</para></summary> /// <param name="setup">the <c>BridgeSetup</c> instance</param> /// <param name="paths">A string containing file paths separated by semicolumn characters</param> public static void AddClassPaths(this BridgeSetup setup, string paths) { if (paths != null) { foreach (string path in paths.Split(';')) { setup.AddClassPath(path); } } }
private static void SetupPhoenixClientJar(string phoenixClientJarPath) { var bridgeSetup = new BridgeSetup() { Verbose = true }; bridgeSetup.AddClassPath(phoenixClientJarPath); Bridge.CreateJVM(bridgeSetup); }
private static void LoadClasspath() { BridgeSetup setup = new BridgeSetup(false); setup.BindNative = false; setup.BindStatic = true; if (config.ClassPath != null && config.ClassPath.Length > 0) { foreach (var classPath in config.ClassPath) { setup.AddClassPath(Path.GetFullPath(classPath.Path)); if (classPath.Generate) { generateCp.Add(classPath.Path); } } } setup.AddBridgeClassPath(); Bridge.CreateJVM(setup); systemClassLoader = ClassLoader.getSystemClassLoader(); }
public virtual void Setup() { Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; var setup = new BridgeSetup(false) { Verbose = true, Debug = true }; string prefix; if (Environment.CurrentDirectory.EndsWith("target")) { prefix = "../../"; } else { prefix = "../../../"; } string userHome = Environment.GetEnvironmentVariable("USERPROFILE"); string version = typeof(BridgeSetup).Assembly.GetName().Version.ToString(); setup.AddClassPath(userHome + @"/.m2/repository/org/picocontainer/picocontainer/2.14.2/picocontainer-2.14.2.jar"); setup.AddClassPath(userHome + @"/.m2/repository/net/sf/jni4net/jni4net.j/" + version + "/jni4net.j-" + version + ".jar"); setup.AddClassPath(prefix + "../../robocode.api/target/Test-classes"); setup.AddClassPath(prefix + "../../robocode.api/target/classes"); setup.AddClassPath(prefix + "../../robocode.battle/target/Test-classes"); setup.AddClassPath(prefix + "../../robocode.battle/target/classes"); setup.AddClassPath(prefix + "../../robocode.core/target/Test-classes"); setup.AddClassPath(prefix + "../../robocode.core/target/classes"); setup.AddClassPath(prefix + "../../robocode.host/target/Test-classes"); setup.AddClassPath(prefix + "../../robocode.host/target/classes"); setup.AddClassPath(prefix + "../../robocode.repository/target/Test-classes"); setup.AddClassPath(prefix + "../../robocode.repository/target/classes"); setup.AddClassPath(prefix + "../../robocode.roborumble/target/Test-classes"); setup.AddClassPath(prefix + "../../robocode.roborumble/target/classes"); setup.AddClassPath(prefix + "../../robocode.samples/target/Test-classes"); setup.AddClassPath(prefix + "../../robocode.samples/target/classes"); setup.AddClassPath(prefix + "../../robocode.sound/target/Test-classes"); setup.AddClassPath(prefix + "../../robocode.sound/target/classes"); setup.AddClassPath(prefix + "../../robocode.tests/target/Test-classes"); setup.AddClassPath(prefix + "../../robocode.tests/target/classes"); setup.AddClassPath(prefix + "../../robocode.ui/target/Test-classes"); setup.AddClassPath(prefix + "../../robocode.ui/target/classes"); setup.AddClassPath(prefix + "../../robocode.ui.editor/target/Test-classes"); setup.AddClassPath(prefix + "../../robocode.ui.editor/target/classes"); setup.AddClassPath(prefix + "robocode.dotnet.api/target/Test-classes"); setup.AddClassPath(prefix + "robocode.dotnet.api/target/classes"); setup.AddClassPath(prefix + "robocode.dotnet.host/target/Test-classes"); setup.AddClassPath(prefix + "robocode.dotnet.host/target/classes"); setup.AddClassPath(prefix + "robocode.dotnet.nhost/target/Test-classes"); setup.AddClassPath(prefix + "robocode.dotnet.nhost/target/classes"); setup.AddClassPath(prefix + "robocode.dotnet.samples/target/Test-classes"); setup.AddClassPath(prefix + "robocode.dotnet.samples/target/classes"); setup.AddClassPath(prefix + "robocode.dotnet.tests/target/Test-classes"); setup.AddClassPath(prefix + "robocode.dotnet.tests/target/classes"); env = Bridge.CreateJVM(setup); Bridge.RegisterAssembly(typeof(TestBase).Assembly); Bridge.RegisterAssembly(typeof(DllRootHelper).Assembly); }
/// <summary>Initialize the jni4net bridge, including creation of the JVM, loading of the appropriate jar files /// and registration of the .Net DLLs.</summary> /// <param name="verbose">whether this method should output verbose statements to the conosle, for debugging puproses</param> public static void Init(bool verbose) { if (verbose) { Console.WriteLine("[JPPFDotnet.Init()]"); } NameValueCollection settings = ConfigurationManager.AppSettings; string jvmOptions = settings["jppf.jvm.option"]; BridgeSetup bridgeSetup = (jvmOptions != null) ? new BridgeSetup(jvmOptions) : new BridgeSetup(true); foreach (string key in settings.AllKeys) { //if (verbose) Console.WriteLine("[JPPFDotnet.Init() : processing " + key + " = " + settings[key]); if (key.StartsWith("ClassPath.")) { if (verbose) { Console.WriteLine("[JPPFDotnet.Init()] adding single classpath for key = '" + key + "' : " + settings[key]); } bridgeSetup.AddClassPath(settings[key]); } else if (key.StartsWith("ClassPaths.")) { string[] parsed = settings[key].Split('|'); if (verbose) { Console.WriteLine("[JPPFDotnet.Init()] adding multiple classpaths for key = '" + key + "' : dir = '" + parsed[0] + "', paths = " + parsed[1]); } bridgeSetup.AddClassPaths(parsed[0], parsed[1]); } else if (key.StartsWith("ClassPathDir.")) { string[] files = Directory.GetFiles(settings[key]); foreach (string file in files) { FileInfo info = new FileInfo(file); bool isDirectory = (info.Attributes & FileAttributes.Directory) == FileAttributes.Directory; if (isDirectory || file.EndsWith(".jar") || file.EndsWith(".zip")) { if (verbose) { Console.WriteLine("[JPPFDotnet.Init()] adding classpath for key = '" + key + "' : " + (isDirectory ? "dir" : "file") + " = '" + file); } bridgeSetup.AddClassPath(file); } } } } if (verbose) { Console.WriteLine("[JPPFDotnet.Init()] bridgeSetup : " + bridgeSetup.JVMCLassPath); foreach (String s in bridgeSetup.JVMCLassPath) { Console.WriteLine(s); } } Bridge.CreateJVM(bridgeSetup); foreach (string key in settings.AllKeys) { if (key.StartsWith("AssemblyPath.")) { if (verbose) { Console.WriteLine("[JPPFDotnet.Init()] adding single assembly for key = '" + key + "' : " + settings[key]); } Bridge.LoadAndRegisterAssemblyByName(settings[key]); } else if (key.StartsWith("AssemblyPaths.")) { string[] parsed = settings[key].Split('|'); if (verbose) { Console.WriteLine("[JPPFDotnet.Init()] registering multiple assemblies for key = '" + key + "' : dir = '" + parsed[0] + "', paths = " + parsed[1]); } Bridge.LoadAndRegisterAssemblyByName(parsed[0] + "\\" + parsed[1]); } } }
private static void LoadClasspath() { BridgeSetup setup=new BridgeSetup(false); setup.BindNative = false; setup.BindStatic = true; if (config.ClassPath != null && config.ClassPath.Length > 0) { foreach (var classPath in config.ClassPath) { setup.AddClassPath(Path.GetFullPath(classPath.Path)); if (classPath.Generate) { generateCp.Add(classPath.Path); } } } setup.AddBridgeClassPath(); Bridge.CreateJVM(setup); systemClassLoader = ClassLoader.getSystemClassLoader(); }