I'm using heroku with maven to run a server. My goal is to have heroku run the java class server.class as a web dyno.
How would I write a procfile to execute the java program server.class as web?
My current Procfile
web: java -cp $JAVA_OPTS target/classes/v1/a1/server
My error.(From heroku logs)
Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8
Error: Could not find or load main class target.classes.v1.a1.server
State changed from starting to crashed
Possibly useful information
The procfile
web: java -cp $JAVA_OPTS target/classes/v1/a1/*
Returns
Error: Could not find or load main class target.classes.v1.a1.myOtherClass
My original Procfile(Also didn't work)
web: java -cp target/classes/:target/dependency/* server
I think your Procfile
should contain:
web: java -cp target/classes/:target/dependency/* v1.a1.server
This assumes the following:
server
class is in the file target/v1/a1/server.class
server
class includes package v1.a1;
A few problems I noticed in your earlier attempts included:
$JAVA_OPTS
to the -cp
options (incorrect)/
instead of .
in the fully qualified class name (incorrect)target
dir in the fully qualified class name (incorrect)The files in the target/classes/
and target/dependency/
directory belong on the classpath (i.e. passed to -cp
) while the last argument to the java
command should be the fully qualified class name (in the form package.Class
).
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments