我尝试从Javascript文件执行Jar文件以获取控制台输出。我已将两个文件都推送到Heroku,但是当我尝试在js文件中调用该函数时,我收到此错误:
/ bin / sh:1:java:找不到exec错误:错误:命令失败:java -jar -Xms1024m MongoConnector-all abaabaa
[31merror [39m:RangeError:超出最大调用堆栈大小
这是我的代码:
const runCoreSearch = function(searchInputString) {
const exec = require('child_process').exec;
//child = exec('/usr/bin/java -jar ~/Applications/Mongo Connector-all.jar' + rakeInputString,
const child = exec('java -jar -Xms1024m MongoConnector-all ' + searchInputString,
function (error, stdout, stderr){
...
在他们的网站(https://devcenter.heroku.com/articles/deploying-executable-jar-files)上,它说要使用命令" heroku deploy:",但我没有尝试部署Java项目,只需执行jar来自node.js项目。有什么想法吗?
答案 0 :(得分:3)
您需要将heroku/jvm
buildpack添加到您的应用并重新部署:
$ heroku buildpacks:add heroku/jvm
$ git commit -m "redeploy" --allow-empty
$ git push heroku master
这会将java
命令安装到您的dyno中。
答案 1 :(得分:1)
我做了codefinger的解决方案,但是遇到了以下错误:
Picked up JAVA_TOOL_OPTIONS -Xmx300m -Xss512k -Dfile.encoding=UTF-8
Error : A JNI error has occured, please check you installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: myClass has been compiled by a more recent version of the Java Runtime (class file version 54.0)...this java version only recognize version up to 52.0
要解决此问题,
文档:https://devcenter.heroku.com/articles/java-support#supported-java-versions