使用javac在Heroku上运行java程序[复制](Run java program on Heroku using javac [duplicate])

这个问题是完全重复的:

试图在Rails Heroku应用上安装Java 1回答

我在Heroku上有一个Ruby on Rails应用程序,需要将一些代码转储到.java文件中并在Heroku终端中运行javac file.java和java file 。 自Java安装以来,代码在本地运行良好,所以我想知道如何在Heroku上安装Java?

This question already has an answer here:

Trying to install Java on a Rails Heroku app 1 answer

I have a Ruby on Rails app on Heroku that needs to dump some code into a .java file and run javac file.java and java file inside Heroku terminal. The code runs fine on local since Java is installed, so I want to know how to install Java on Heroku?

最满意答案

您需要运行以下命令将heroku/jvm buildpack添加到您的应用程序中:

$ heroku buildpacks:add -i 1 heroku/jvm

然后重新部署,然后将其展示给javac 。

但是,这可能不是你想要完成你想要做的事情的方式。 我怀疑在构建阶段(当你运行git push )运行javac会更好,这样你编译的Java .class文件就可以预编译了。

为此,您可以将javac调用放入assets:precompile Rake任务,如下所示:

task "assets:precompile" do `javac File.java` end

然后它将作为构建的一部分运行。

You'll want to add the heroku/jvm buildpack to your app by running:

$ heroku buildpacks:add -i 1 heroku/jvm

Then redeploy, and shell out to javac.

However, this is probably not the way you want to accomplish what you're trying to do. I suspect it would be better to run javac during the build-phase (when you run git push) so that your compiled Java .class file is available to you app precompiled.

To do this, you can put your javac call in your assets:precompile Rake task like this:

task "assets:precompile" do `javac File.java` end

Then it will run as part of your build.

使用javac在Heroku上运行java程序[复制](Run java program on Heroku using javac [duplicate])

这个问题是完全重复的:

试图在Rails Heroku应用上安装Java 1回答

我在Heroku上有一个Ruby on Rails应用程序,需要将一些代码转储到.java文件中并在Heroku终端中运行javac file.java和java file 。 自Java安装以来,代码在本地运行良好,所以我想知道如何在Heroku上安装Java?

This question already has an answer here:

Trying to install Java on a Rails Heroku app 1 answer

I have a Ruby on Rails app on Heroku that needs to dump some code into a .java file and run javac file.java and java file inside Heroku terminal. The code runs fine on local since Java is installed, so I want to know how to install Java on Heroku?

最满意答案

您需要运行以下命令将heroku/jvm buildpack添加到您的应用程序中:

$ heroku buildpacks:add -i 1 heroku/jvm

然后重新部署,然后将其展示给javac 。

但是,这可能不是你想要完成你想要做的事情的方式。 我怀疑在构建阶段(当你运行git push )运行javac会更好,这样你编译的Java .class文件就可以预编译了。

为此,您可以将javac调用放入assets:precompile Rake任务,如下所示:

task "assets:precompile" do `javac File.java` end

然后它将作为构建的一部分运行。

You'll want to add the heroku/jvm buildpack to your app by running:

$ heroku buildpacks:add -i 1 heroku/jvm

Then redeploy, and shell out to javac.

However, this is probably not the way you want to accomplish what you're trying to do. I suspect it would be better to run javac during the build-phase (when you run git push) so that your compiled Java .class file is available to you app precompiled.

To do this, you can put your javac call in your assets:precompile Rake task like this:

task "assets:precompile" do `javac File.java` end

Then it will run as part of your build.