1

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

Community
  • 1
  • 1
Misael P
  • 387
  • 1
  • 4
  • 10

3 Answers3

3

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
codefinger
  • 10,088
  • 7
  • 39
  • 51
  • 1
    This helped me a lot to find the right solution, for the record Im gonna add a new answer but I will mark it as the valid. – Misael P Sep 09 '14 at 00:01
3

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

Misael P
  • 387
  • 1
  • 4
  • 10
1

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

Travis Well
  • 947
  • 10
  • 32