Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError [ERR_UNKNOWN_ENCODING]: Unknown encoding: null #39

Open
lolouthefox opened this issue Dec 2, 2023 · 0 comments
Open

TypeError [ERR_UNKNOWN_ENCODING]: Unknown encoding: null #39

lolouthefox opened this issue Dec 2, 2023 · 0 comments

Comments

@lolouthefox
Copy link

I'm getting this error, I'm not sure if it's a problem with me or my jar file. I can't modify the file since it's downloaded from internet...

import JVM from "node-jvm";
import path from "path";

export class ServerJVM {
  #jvm;
  #entryPointClassName;

  constructor() {
    this.#jvm = new JVM();
    this.#jvm.setLogLevel(7);
    console.log(path.resolve("./server/server.jar"));
    this.#entryPointClassName = this.#jvm.loadJarFile(path.resolve("./server/server.jar"), "UTF-8");
    this.#jvm.setEntryPointClassName(this.#entryPointClassName);
  }

  async startServer({ onExit }) {
    this.#jvm.on("exit", function (code) {
      onExit(code);
    });
    this.#jvm.run([15]);
  }
}
node:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_UNKNOWN_ENCODING]: Unknown encoding: null
    at new NodeError (node:internal/errors:405:5)
    at Buffer.toString (node:buffer:863:11)
    at Reader.readString (C:\Users\liamc\Programming\Javascript\mcm\puppet\node_modules\node-jvm\libs\util\reader.js:34:27)
    at getClassImage (C:\Users\liamc\Programming\Javascript\mcm\puppet\node_modules\node-jvm\libs\classfile\classarea.js:172:36)
    at new module.exports (C:\Users\liamc\Programming\Javascript\mcm\puppet\node_modules\node-jvm\libs\classfile\classarea.js:15:27)
    at Classes.loadClassBytes (C:\Users\liamc\Programming\Javascript\mcm\puppet\node_modules\node-jvm\libs\classes.js:47:21)
    at C:\Users\liamc\Programming\Javascript\mcm\puppet\node_modules\node-jvm\libs\classes.js:86:22
    at Array.forEach (<anonymous>)
    at Classes.loadJarFile (C:\Users\liamc\Programming\Javascript\mcm\puppet\node_modules\node-jvm\libs\classes.js:82:16)
    at JVM.loadJarFile (C:\Users\liamc\Programming\Javascript\mcm\puppet\node_modules\node-jvm\libs\jvm.js:81:20) {
  code: 'ERR_UNKNOWN_ENCODING'
}

Node.js v18.18.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant