Skip to content

Commit 4ed122e

Browse files
authored
merge from master to my fork (#1)
* fixed arm stuff * added raspi hack * issue with opensdk on arm * Update README.md * v0.7.1 * added compile java (1.7) for windows * added event listener test * fixed a bug on win-64bit * v0.7.2
1 parent 653ff1c commit 4ed122e

12 files changed

Lines changed: 79 additions & 3 deletions

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ npm test
5858

5959
_NOTE: You will need node-gyp installed using "npm install -g node-gyp"_
6060

61+
On Raspian you might need a:
62+
63+
* sudo ln -s /usr/lib/jvm/jdk-7-oracle-arm-vfp-hflt /opt/jdk
64+
65+
Some issues with the OpenSDK7 so take the Oracle version for compiling.
66+
6167
## Docker
6268

6369
If you want to play with node-java but don't want to setup the build environment you can run it in docker.

binding.gyp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
['OS=="mac"', {
2525
'javaver%' : "<!(awk -F/ -v h=`node findJavaHome.js` 'BEGIN {n=split(h, a); print a[2]; exit}')"
2626
}],
27+
['OS=="linux" and target_arch=="arm"', {
28+
'javalibdir%': "<!(h=\"`node findJavaHome.js`\" sh -c 'if [ -d \"$h/jre/lib/arm/classic\" ]; then echo $h/jre/arm/i386/classic; else echo $h/jre/lib/arm/server; fi')"
29+
}],
2730
['OS=="linux" and target_arch=="ia32"', {
2831
'javalibdir%': "<!(h=\"`node findJavaHome.js`\" sh -c 'if [ -d \"$h/jre/lib/i386/classic\" ]; then echo $h/jre/lib/i386/classic; else echo $h/jre/lib/i386/server; fi')"
2932
}],

compile-java-code.cmd

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
set JAVA_VERSION=1.7
2+
3+
set OUTFILE="%TMP%\findJavaHome.txt"
4+
node findJavaHome.js > %OUTFILE%
5+
set /p JAVA_HOME=<%OUTFILE%
6+
7+
set JAVAC_OPTS=-source %JAVA_VERSION% -target %JAVA_VERSION% -bootclasspath "%JAVA_HOME%\jre\lib\rt.jar"
8+
9+
cd test
10+
"%JAVA_HOME%\bin\javac" %JAVAC_OPTS% *.java
11+
12+
cd ..\src-java\node
13+
"%JAVA_HOME%\bin\javac" %JAVAC_OPTS% *.java
14+
15+
cd ..\..\
16+
"%JAVA_HOME%\bin\javah" -classpath src-java -d .\src node.NodeDynamicProxyClass

compile-java8-code.cmd

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set JAVA_VERSION=1.8
2+
3+
set OUTFILE="%TMP%\findJavaHome.txt"
4+
node findJavaHome.js > %OUTFILE%
5+
set /p JAVA_HOME=<%OUTFILE%
6+
7+
cd test8
8+
"%JAVA_HOME%\bin\javac" -source %JAVA_VERSION% *.java

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"jvm",
88
"bridge"
99
],
10-
"version": "0.7.0",
10+
"version": "0.7.2",
1111
"engines": {
1212
"node": ">=0.10.0"
1313
},

src/java.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ NAN_METHOD(Java::newProxy) {
452452
jclass objectClazz = env->FindClass("java/lang/Object");
453453
jobjectArray methodArgs = env->NewObjectArray(2, objectClazz, NULL);
454454
env->SetObjectArrayElement(methodArgs, 0, v8ToJava(env, Nan::New<v8::String>(s_nativeBindingLocation.c_str()).ToLocalChecked()));
455-
env->SetObjectArrayElement(methodArgs, 1, longToJavaLongObj(env, (long)dynamicProxyData));
455+
env->SetObjectArrayElement(methodArgs, 1, longToJavaLongObj(env, (jlong)dynamicProxyData));
456456
jobject method = javaFindConstructor(env, clazz, methodArgs);
457457
if(method == NULL) {
458458
std::ostringstream errStr;

test/ListenerInterface.class

265 Bytes
Binary file not shown.

test/ListenerInterface.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public interface ListenerInterface {
2+
void onEvent(java.util.ArrayList<String> list, java.lang.Runtime runtime);
3+
}

test/ListenerTester.class

756 Bytes
Binary file not shown.

test/ListenerTester.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
public class ListenerTester {
2+
private ListenerInterface _listener;
3+
4+
public void setListener(ListenerInterface listener) {
5+
this._listener = listener;
6+
}
7+
8+
public void raiseEvent() {
9+
if(this._listener == null)
10+
return;
11+
12+
java.util.ArrayList<String> list = new java.util.ArrayList<String>();
13+
list.add("hello");
14+
list.add("from");
15+
list.add("Java");
16+
17+
this._listener.onEvent(list, java.lang.Runtime.getRuntime());
18+
}
19+
}

0 commit comments

Comments
 (0)