My favorites | Sign in
Project Home Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#region Copyright (C) 2009 by Pavel Savara

/*
This file is part of tools for jni4net - bridge between Java and .NET
http://jni4net.sourceforge.net/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#endregion

using java.io;
using java.lang;
using java.util;
using net.sf.jni4net;
using net.sf.jni4net.adaptors;

namespace helloWorldFromCLR
{
public class Program
{
private static void Main()
{
// create bridge, with default setup
// it will lookup jni4net.j.jar next to jni4net.n.dll
Bridge.CreateJVM(new BridgeSetup(){Verbose=true});

// here you go!
java.lang.System.@out.println("Hello Java world!");

// OK, simple hello is boring, let's play with Java properties
// they are Hashtable realy
Properties javaSystemProperties = java.lang.System.getProperties();

// let's enumerate all keys.
// We use Adapt helper to convert enumeration from java o .NET
foreach (java.lang.String key in Adapt.Enumeration(javaSystemProperties.keys()))
{
java.lang.System.@out.print(key);

// this is automatic conversion of CLR string to java.lang.String
java.lang.System.@out.print(" : ");

// we use the hashtable
Object value = javaSystemProperties.get(key);

// and this is CLR ToString() redirected to Java toString() method
string valueToString = value.ToString();
java.lang.System.@out.println(valueToString);
}

// Java output is really Stream
PrintStream stream = java.lang.System.@out;

// it implements java.io.Flushable interface
Flushable flushable = stream;
flushable.flush();
}
}
}

Change log

r863 by pavel.savara on Jul 6, 2011   Diff
- updated hello samples to be verbose
- runtime dumps versions when verbose
- proxygen dumps versions
- added CLR 4.0 as preferred runtime for
proxygen
Go to: 
Project members, sign in to write a code review

Older revisions

r324 by pavel.savara on Nov 22, 2009   Diff
enumeration adapter
sample improved
r258 by pavel.savara on Oct 9, 2009   Diff
[No log message]
r219 by pavel.savara on Sep 20, 2009   Diff
license headers
All revisions of this file

File info

Size: 2508 bytes, 71 lines
Powered by Google Project Hosting