Re: How to pass command line arguments to spring java app


Ben Hale <bhale@...>
 

The Java Main Container configuration documentation[1] describes the appropriate way to set command line arguments. Configuration can be done either with a fork of the buildpack or an environment variable.

```
$ cf set-env <APP> JBP_CONFIG_JAVA_MAIN ‘{arguments: “arg1 arg2”}’
```


-Ben Hale
Cloud Foundry Java Experience


[1]: https://github.com/cloudfoundry/java-buildpack/blob/master/docs/container-java_main.md#configuration

On Dec 2, 2015, at 14:43, Evan Farrar <evanfarrar(a)gmail.com> wrote:

I spoke too soon, I think that is the opposite of what you are looking for, sorry!

On Wed, Dec 2, 2015 at 2:39 PM, Evan Farrar <evanfarrar(a)gmail.com> wrote:
Hey!

I think the thing you are looking for is the JAVA_OPTS env variable:

https://github.com/cloudfoundry/java-buildpack/blob/master/docs/framework-java_opts.md

On Wed, Dec 2, 2015 at 2:34 PM, Lakshman Mukkamalla (lmukkama) <lmukkama(a)cisco.com> wrote:
Hi CF dev team,
I want to pass command line arguments to the spring java app. I have tried the option of setting them using the env ‘JBP_CONFIG_JAVA_MAIN’ as suggested in https://github.com/cloudfoundry/java-buildpack but its not working. Could anyone suggest what is the right way to pass the command line arguments. Currently the app is started with following command.
App xyz was started using this command `SERVER_PORT=$PORT $PWD/.java-buildpack/open_jdk_jre/bin/java -cp $PWD/.:$PWD/.java-buildpack/spring_auto_reconfiguration/spring_auto_reconfiguration-1.7.0_RELEASE.jar -Djava.io.tmpdir=$TMPDIR -XX:OnOutOfMemoryError=$PWD/.java-buildpack/open_jdk_jre/bin/killjava.sh -Xmx768M -Xms768M -XX:MaxMetaspaceSize=104857K -XX:MetaspaceSize=104857K -Xss1M -Dlogging.config=file:/home/vcap/app/logback.xml org.springframework.boot.loader.JarLauncher`

How the app is pushed: cf push –p xyz.jar

Thanks.

Join cf-dev@lists.cloudfoundry.org to automatically receive all group messages.