Question

In IntelliJ 13.0.2 Ultimate I've set up a web application module using Jetty 9.1.4.

I'd like to test my application on port 8100, but I can't figure out a way to change the port of my "Local" Jetty run configuration. It always seems to use the default port 8080.

There is a setting for the port in the IntelliJ run configuration but it only appears when configuring a "remote" server.

I've tried adding my own .mod file to the Jetty Server Settings containing the following but it seems to be ignored.

[ini-template]
jetty.port=8100

One of the answers in this post says the port is 8080 unless you change it, but he doesn't say how to change it.

Can someone point me in the right direction? Thanks!

Was it helpful?

Solution 3

IntelliJ support says the port should be edited in start.ini file (in the root directory of Jetty installation), so it seems it is not possible to set it in IntelliJ.

The other alternative of course is to embed Jetty as a library in a standard java application instead of creating a web application based on Jetty.

OTHER TIPS

You can specify the port in the VM-properties in the instance of your Jetty-VM

-Djetty.port=8100

Tested with Jetty 8.1.xxx with IntelliJ 13.1 but should work on many versions I suppose

UPDATE 1: For Jetty 9 (and up probably) following setting should be used, thx Ingo Kegel

-Djetty.http.port=8100

You can change the Jetty port in the file start.d/http.ini, e.g.

## HTTP port to listen on
jetty.port=8180

Neither of the suggeted above worked for me. The only way I found was to add

<Configure class="org.eclipse.jetty.server.Server" id="Server">
....
    <Set name="connectors">
        <Array type="org.eclipse.jetty.server.Connector">
            <Item>
                <New class="org.eclipse.jetty.server.ServerConnector">
                    <Arg><Ref refid="ExampleServer"/></Arg>
                    <Set name="port">8081</Set>
                </New>
            </Item>
        </Array>
</Set>

to the tmp context generated by Idea, one that appears last in the command line it uses to start jetty:

/opt/java/bin/java -... org.eclipse.jetty.start.Main etc/jetty-jmx.xml /tmp/context6config/contexts-config.xml

The jetty I tried with was 9.3.5

Edit the start.ini file inside the JETTY_HOME folder, uncomment and change the jetty.http.port line

Below is an example changing it to port 8078

## Connector port to listen on
jetty.http.port=8078
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top