简体   繁体   English

/app/.jdk/bin/java:无法在 Heroku 上使用 node-pty 执行二进制文件

[英]/app/.jdk/bin/java: cannot execute binary file using node-pty on Heroku

I am trying to create a node-pty process.我正在尝试创建一个 node-pty 进程。 When developing locally, this works fine and there is no problem.在本地开发时,这工作正常,没有问题。 However, when this runs on Heroku, it gives the error: /app/.jdk/bin/java: cannot execute binary file但是,当它在 Heroku 上运行时,会出现错误: /app/.jdk/bin/java: cannot execute binary file

I tried running it with just ["java"] , and that gives the same error.我尝试只用["java"]运行它,这给出了同样的错误。 So, its unable to start the java binary.因此,它无法启动 java 二进制文件。

However, when I manually type the command, it works just fine.但是,当我手动键入命令时,它工作得很好。

  const shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash';

  const ptyProcess = pty.spawn(shell, ["java", "-jar", "Klox.jar"], {
    name: 'xterm-color',
    cols: 80,
    rows: 30,
    cwd: process.env.HOME,
    env: process.env
  });

Any idea how I can solve this?知道如何解决这个问题吗?

Solved the problem,解决了问题,

Instead of spawning the shell with powershell or bash, spawn the shell directly with the executable that you're trying to run. Instead of spawning the shell with powershell or bash, spawn the shell directly with the executable that you're trying to run. So, java in my case.所以,就我而言, java

Effectively, what I did:实际上,我做了什么:

  const ptyProcess = pty.spawn("java", ["-jar", "Klox.jar"], {
    name: 'xterm-color',
    cols: 80,
    rows: 30,
    cwd: process.env.HOME,
    env: process.env
  });

So, "java" instead of old shell variable.因此,“java”而不是旧的 shell 变量。

One another thing to keep in mind, on windows add .exe extension to the end, otherwise it will say file not found.还有一件事要记住,在 windows 上添加.exe扩展名到末尾,否则会说找不到文件。 For eg: java.exe on windows and java on linux.例如: java.exe上的 java.exe 和java上的 java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 / bin / sh:/usr/jdk64/jdk1.7.0_45/bin/java:无法执行二进制文件 - /bin/sh: /usr/jdk64/jdk1.7.0_45/bin/java: cannot execute binary file -bash:./jdk-6u31-linux-i586.bin:无法执行二进制文件 - -bash: ./jdk-6u31-linux-i586.bin: cannot execute binary file Java lang.process运行jar“/ usr / bin / java:无法执行二进制文件” - Java lang.process run jar “/usr/bin/java: cannot execute binary file” 如何使用Java将8位二进制值存储和检索到bin文件中 - how to store and retrieve a 8 bit binary value into a bin file using java 运行Java应用程序时,Eclipse显示“无法执行二进制文件” - Eclipse shows “Cannot execute binary file” when running Java application 如何使用JDK二进制文件运行Java类文件? - How to run a Java class file with a jdk binary? 蚂蚁构建失败,“ idl2java:无法执行二进制文件” - Ant build failing, “idl2java: cannot execute binary file” jdk / bin / java和jdk / jre / bin / java之间的差异 - Diference between jdk/bin/java and jdk/jre/bin/java HEROKU - 无法使用 jdk11 部署 java 应用程序 - HEROKU - can't deploy java app with jdk11 “jdk1.8.0_121/bin”中的“java”文件和“jdk1.8.0_121/jre/bin”中的“java”文件有什么区别? - Whats the difference between the “java” file found in “jdk1.8.0_121/bin” and the one that's in “jdk1.8.0_121/jre/bin”?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM