diff --git a/src/main/java/com/eclipsesource/v8/NodeJS.java b/src/main/java/com/eclipsesource/v8/NodeJS.java index 30d148364..328f8f7b1 100644 --- a/src/main/java/com/eclipsesource/v8/NodeJS.java +++ b/src/main/java/com/eclipsesource/v8/NodeJS.java @@ -98,7 +98,7 @@ public void invoke(final V8Object receiver, final V8Array parameters) { try { File startupScript = createTemporaryScriptFile(STARTUP_SCRIPT, STARTUP_SCRIPT_NAME); try { - v8.createNodeRuntime(startupScript.getAbsolutePath()); + v8.createNodeRuntime(startupScript.getCanonicalPath()); } finally { startupScript.delete(); } @@ -165,9 +165,11 @@ public V8Object require(final File file) { v8.checkThread(); V8Array requireParams = new V8Array(v8); try { - requireParams.push(file.getAbsolutePath()); + requireParams.push(file.getCanonicalPath()); return (V8Object) require.call(null, requireParams); - } finally { + } catch (IOException e) { + throw new RuntimeException(e); + }finally { requireParams.close(); } } @@ -202,8 +204,10 @@ private V8Function createScriptExecutionCallback(final File file) { public Object invoke(final V8Object receiver, final V8Array parameters) { V8Array requireParams = new V8Array(v8); try { - requireParams.push(file.getAbsolutePath()); + requireParams.push(file.getCanonicalPath()); return require.call(null, requireParams); + } catch (IOException e) { + throw new RuntimeException(e); } finally { requireParams.close(); }