问题
I have an error following the next tutorial from Heroku specifically on this part
[https://devcenter.heroku.com/articles/getting-started-with-java#run-the-app-locally][1]
If I execute that instruction foreman throws the following error:
Error: cannot find java class $JAVA_OPTS
I have already declared a env variable like this:
Name variable : JAVA_OPTS
Variable value: -Xms256m -Xmx512m
The Proc file that foreman is trying to execute has the following:
web: java $JAVA_OPTS -cp target/classes:target/dependency/* Main
Im clueless about what is happening.
Note: I already checked some other questions
Running java with JAVA_OPTS env variable
Foreman terminates immediately
foreman can't find java
Hope someone knwos what is happening.
EDIT : I answered my own question below
回答1:
I suspect you are running on Windows. If so, then you'll have to reference the JAVA_OPTS var like %JAVA_OPTS%
. But Heroku will still need the *nix style ($JAVA_OPTS
), so I recommend creating a Procfile.win
next to your Procfile
with the following contents:
web: java %JAVA_OPTS% -cp target/classes:target/dependency/* Main
Then run this to start your app locally:
$ foreman start --procfile=Procfile.win
回答2:
This is what I did in order to solve the issue:
Seems that the documentation at heroku site is not clear about what operating system are you using. But then I found the answer in the link below:
Heroku Deploy your Java app locally
The original Proc file script whas like this:
web: java $JAVA_OPTS -cp target/classes:target/dependency/* Main
and I modified it as you can see below:
web: java %JAVA_OPTS% -cp target\classes;"target\dependency\*" Main
Just as Heroku documentation states.
This solved the problem and I was able to run my app locally
回答3:
If you're using 'nix,
export JAVA_OPTS
before running the script that expects it.
来源:https://stackoverflow.com/questions/25713640/foreman-cannot-find-java-opts