private void CompileJavaProgram() { String code = @" package com.db4o.test.aliases; import com.db4o.*; class Person2 { String _name; public Person2(String name) { _name = name; } } public class Program { public static void main(String[] args) { String fname = args[0]; ObjectContainer container = Db4o.openFile(fname); container.store(new Person2(""Homer Simpson"")); container.store(new Person2(""John Cleese"")); container.close(); System.out.println(""success""); } }"; JavaServices.ResetJavaTempPath(); string stdout = JavaServices.CompileJavaCode("com/db4o/test/aliases/Program.java", code); Console.WriteLine(stdout); }
private void CompileJavaSnippet() { JavaServices.ResetJavaTempPath(); JavaSnippet program = JavaCode(); string stdout = JavaServices.CompileJavaCode(program.MainClassFile, program.SourceCode); Console.WriteLine(stdout); }
protected void CompileJava(JavaSnippet snippet) { if (!AlreadyCompiled(snippet.MainClassName)) { FlagAsCompiled(snippet.MainClassName); JavaServices.CompileJavaCode(snippet.MainClassFile, snippet.SourceCode); } }
private void CompileJavaCode() { JavaSnippet snippet = JavaCode(); JavaServices.ResetJavaTempPath(); string @out = JavaServices.CompileJavaCode(snippet.MainClassFile, PopulateItemValues(snippet.SourceCode)); Console.Error.WriteLine(@out); }
protected override void StartServer() { ThreadPool.QueueUserWorkItem(delegate { JavaServices.CompileJavaCode(JavaServerCode.MainClassFile, JavaServerCode.SourceCode); string output = JavaServices.java(JavaServerCode.MainClassName, Port.ToString(), USER_NAME, USER_PWD, Debugger.IsAttached.ToString()); if (output.Length > 0) { Assert.Fail("\r\n\r\n****** Java Server returned an error ********\r\n\r\n" + output); } }); }
private static void CompileJavaApplication() { const string code = @" package NetArrayFromJava; import com.db4o.*; import com.db4o.foundation.*; import com.db4o.config.*; import com.db4o.query.*; class Item { private String _description; private byte[] _byteArray; private int[] _intArray; private float[] _floatArray; public String toString() { return ""Item("" + _description + "", "" + byteArrayString() + "", "" + intArrayString() + "", "" + floatArrayString() + "")""; } public String byteArrayString() { if (null == _byteArray) return null; Collection4 c = new Collection4(); for (int i=0; i<_byteArray.length; ++i) c.add(new Byte(_byteArray[i])); return c.toString(); } public String intArrayString() { if (null == _intArray) return null; Collection4 c = new Collection4(); for (int i=0; i<_intArray.length; ++i) c.add(new Integer(_intArray[i])); return c.toString(); } public String floatArrayString() { if (null == _floatArray) return null; Collection4 c = new Collection4(); for (int i=0; i<_floatArray.length; ++i) c.add(new Float(_floatArray[i])); return c.toString(); } } public class Program { public static void main(String[] args) { String fname = args[0]; String typeName = args[1]; //System.out.println(fname); if (!new java.io.File(fname).exists()) { System.out.println(""'"" + fname + ""' not found.""); } Configuration configuration = Db4o.newConfiguration(); configuration.addAlias(new TypeAlias(typeName, ""NetArrayFromJava.Item"")); configuration.add(new DotnetSupport()); ObjectContainer container = Db4o.openFile(configuration, fname); try { ObjectSet found = queryItems(container); System.out.println(""**""); while (found.hasNext()) { System.out.println(found.next()); } System.out.println(""**""); } finally { container.close(); } } static ObjectSet queryItems(ObjectContainer container) { Query q = container.query(); q.constrain(Item.class); q.descend(""_description"").orderAscending(); return q.execute(); } } "; JavaServices.CompileJavaCode("NetArrayFromJava/Program.java", code); }