Trying to install Java on a Rails Heroku app - java

My Rails app relies on legacy Java code for a piece of its logic. It runs the code via shell commands: javac whatever and then java whatever. However, after deploying to Heroku, the request fails because it can't locate javac or java.
What's the best way to install Java in a Rails app? I tried using a multi-buildpack solution, with this .buildpacks:
https://github.com/heroku/heroku-buildpack-ruby.git
https://github.com/heroku/heroku-buildpack-java.git
But I get this error:
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-java.git
! Push rejected, failed to compile Multipack app
I tried forking the Ruby buildpack and installing Java directly from there, but I don't really know what I'm doing. Any ideas?

Try using heroku-buildpack-jvm-common instead of the Java buildpack. So your .buildpacks file will look like this:
https://github.com/heroku/heroku-buildpack-jvm-common.git
https://github.com/heroku/heroku-buildpack-ruby.git
It's probably a good idea to put the JVM one before the Ruby one in case javac or java are needed at compile/build time.
The JVM buildpack is essentially the same as the Java buildpack, but doesn't install Maven and thus does not require a pom.xml file. The missing pom.xml is why you got that error I think.
EDIT
In the modern era, you can also run:
$ heroku buildpacks:add heroku/jvm
$ heroku buildpacks:add heroku/ruby

Related

How to embed JyNI in a jar

I'm developing an application in java, and in this one, I use jython-standalone (Jython for untold reasons, its goal being to ease some scripting within the application).
I would like to have access to NumPy, and it seems that JyNI provides such capabilities.
I found many posts explaining how to start a Jython project using JyNI, but none on how to include the .jar or something in the application so that it is available when needed.
As stated on JyNI, java -cp build/JyNI.jar -jar jython.jar does not work.
Is there a way for me to use JyNI when executing some Jython code through a PythonInterpreter ?
You should be able to start the live interpreter by executing the class org.python.util.jython.
On Linux, OSX:
java -cp jython.jar:build/JyNI.jar org.python.util.jython
On Windows:
java -cp jython.jar;build\JyNI.jar org.python.util.jython
Alternatively, one can use Jython's start script:
jython -J-cp build/JyNI.jar
This info is taken from https://github.com/Stewori/JyNI#running-jyni, but leaving out the script argument someFile.py.
If you want to explicitly leverage the interpreter through Java code, you will surely have some way to launch your overall application. Make sure to have JyNI.jar and the folder containing its binaries on classpath in that command. Jython should be running with JyNI support then.
A side-note: Be sure to use Jython 2.7.1 and NumPy >= 1.12. Version mismatch of these prerequisites is a common cause of failure.

Running a java subprocess from a python app in Heroku

I am new to Heroku. The backend logic of my flask web app is actually running a Java subprocess (subprocess.call( ...) ) to get some helper data. (I know it's a bad thing to do)
On deployment, Heroku works as expected and installs Python runtime and frameworks from requirements.txt but not JDK.
Any way I can configure Java in the same and make this work ??
Run the following command:
$ heroku buildpacks:add heroku/jvm
Then redeploy with a git push heroku master. This will install the JDK into your slug.

Can't compile GWT application on AWS instance (Linux)

I'm getting an error when trying to compile a GWT application on an AWS EC2 Instance under AMI Linux.
I already installed Java and have it in directory /usr/lib/jvm/java-1.7.0-openjdk.x86_64.
I also set up the enviroment variables:
$JAVA_HOME = /usr/lib/jvm/java-1.7.0-openjdk.x86_64
$PATH = /sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin;/usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin
So, when I try to run the command:
java -cp
"/var/lib/gwt/gwt-2.6.1/gwt-dev.jar;/var/my-project-source-folder"
com.google.gwt.dev.Compiler com.mypackage.MyClass
I'm getting this error:
Error: Could not find or load main class com.google.gwt.dev.Compiler
I downloaded and unziped GWT 2.6.1 again but the files are fine. The same command is working perfectly in my Windows machine. Do you know what's happening?
Ok, this is embarrassing.
Here is the answer:
I was separating the paths with ; (Windows) instead of : (Linux). BTW, who would think in separate things with :, you Linux guys know how to make hard the easy...

Getting error in installing scala

i follow the tutorial https://class.coursera.org/progfun-005/lecture/21
to install Scala.
I have already java install in it.As the tutorial guides i download the latest sbt and install it.
But when i am trying to run in command prompt by typing
sbt sbtVersion it gives an error that "Files was unexpected at this time"
I am new in this so ignore if i am making any silly error
Download the jar and run it using java -jar /location/of/the/downloaded/jar/from/the/previous/link -- leave a comment if you have further problems.

Troubleshooting with installation newrelic agent on tomcat

Trying to install java agent on tomcat.
successfully run
java -jar newrelic.jar install
then run apache, but not see any newrilc initialization messages in catalina out, and not found any logs in newrelic directory.
General guidance on this install process:
The script should print out a good amount of detail on what it's done, including where it detected your Tomcat instance. If nothing's showing up in your CLI, then it's likely you haven't started the install script.
You can use -h to see usage help, and -s /path/to/applicationserver if you want to make sure the script find your web app. Note that a clear error message should show up if the install script can't find your web app.
The install script is fairly simple, and you can perform a manual install with the steps in the New Relic documentation (broken out by framework).

Categories

Resources