Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Heroku application run locally with foreman

I'm following the "Getting Started with Java on Heroku" guide at https://devcenter.heroku.com/articles/getting-started-with-java I follow the steps till I deploy and execute succesfully the application downloaded from GitHub. When I try to execute it locally on Windows XP with the command

foreman start web

I get the error:

    web.1  | started with pid 3388
    web.1  | Error: Could not find or load main class Main
    web.1  | exited with code 1
    system | sending SIGKILL to all processes

My Procfile is:

web:    java %JAVA_OPTS% -cp target\classes:target\dependency\* Main

And

>echo %JAVA_OPTS%
-Xms256m -Xmx512m

Can anyone suggest me how to solve?

like image 486
grandeale83 Avatar asked Sep 29 '14 12:09

grandeale83


People also ask

Can I host a Java application on Heroku?

You can deploy any Java application on Heroku. It is not limited to JEE or other frameworks. You can deploy Java web applications packaged as WAR files using WAR deployment or you can deploy Maven based Java projects of any kind using the git versioning system.

How do I run an app locally?

Running your application locallySelect File > Open to open the project you want to run. Browse to the directory containing your project. Select Tools > Cloud Code > App Engine Run on a local App Engine Standard dev server.


2 Answers

I ran into this issue while running through the https://devcenter.heroku.com/articles/getting-started-with-java tutorial.

After tinkering with some of these answers I discovered that step six at https://devcenter.heroku.com/articles/getting-started-with-java#define-a-procfile tells the answer.

When you see instructions to run your app with foreman, append an extra -f Procfile.windows flag to ensure your Windows-specific Procfile is picked up. For example: foreman start web -f Procfile.windows

Once I switched to the foreman start web -f Procfile.windows command, everything worked smoothly.

like image 28
DJ Martin Avatar answered Sep 22 '22 05:09

DJ Martin


Quotes and semicolon

web: java %JAVA_OPTS% -cp target\classes;"target\dependency\*"  Main
like image 110
user2818782 Avatar answered Sep 19 '22 05:09

user2818782