You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i tried to make a small node js calling jar file that function to call hello world it works normall if i just run node test.js. but if i build the package into .exe using pkg method it gives out this error can someone help me?
var clazz = java.findClassSync(name); // TODO: change to Class.forName when classloader issue is resolved.
^
Error: Could not create class Test
java.lang.NoClassDefFoundError: Test
Caused by: java.lang.ClassNotFoundException: Test
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at Java.import (C:\snapshot\test-node-java\node_modules\←[4mjava←[24m\lib\nodeJavaBridge.js:227:20)
at Object.<anonymous> (C:\snapshot\test-node-java\test.js:4:23)
at Module._compile (pkg/prelude/bootstrap.js:1930:22)
←[90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)←[39m
←[90m at Module.load (node:internal/modules/cjs/loader:981:32)←[39m
←[90m at Function.Module._load (node:internal/modules/cjs/loader:822:12)←[39m
at Function.runMain (pkg/prelude/bootstrap.js:1983:12)
←[90m at node:internal/main/run_main_module:17:47←[39m {
cause: nodeJava_java_lang_NoClassDefFoundError {}
}
this is the js code
var java = require('java');
java.classpath.push('test-node-java.jar');
let test = java.import('Test');
test.hello();
console.log(test)
this is the java code
import java.lang.System;
public class Test {
public static void hello() {
System.out.println("Hello Java");
}
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
all the files are under the same directory including the test-node-java.jar
The text was updated successfully, but these errors were encountered:
Y-christian
changed the title
java.lang.NoClassDefFoundErrorafter complie into executable
java.lang.NoClassDefFoundError after compiled into executable
Jan 5, 2023
i tried to make a small node js calling jar file that function to call hello world it works normall if i just run node test.js. but if i build the package into .exe using pkg method it gives out this error can someone help me?
this is the js code
this is the java code
this is the package.json
all the files are under the same directory including the test-node-java.jar
The text was updated successfully, but these errors were encountered: