Search code examples
eclipsemavenjarhttp-status-code-504

Difference between `run as java application` in eclipse and `java -jar xxx.jar` from cmd line?


I'm writing a tool to call another service, and got a weird problem. When i run the main method file as java application in eclipse, it works fine, but after i build it as a jar and run it from cmd line like java -jar xxx.jar with exactly the same arguments, i got a 504 gateway timeout(responses are huge but works weirdly fine in eclipse). And actually it runs faster in eclipse, any idea? It works well on both when asking for a small amount of responses.


Solution

  • Maybe Eclipse is using better JVM settings when it runs the application (i.e. larger heap size).

    Try to increase your max heap size (Xmx) when running the JAR:

    java -jar yourapp.jar -Xmx1024m
    

    Get inspiration from here: How to set the -Xmx when start running a jar file?