Foreman cannot find $JAVA_OPTS

2019-05-31 22:18发布

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

3条回答
叼着烟拽天下
2楼-- · 2019-05-31 22:58

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
查看更多
一纸荒年 Trace。
3楼-- · 2019-05-31 23:08

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

查看更多
来,给爷笑一个
4楼-- · 2019-05-31 23:11

If you're using 'nix, export JAVA_OPTS before running the script that expects it.

查看更多
登录 后发表回答