It's easy to change GlassFish port number through Administration Console. But how to do it through command line? Yes, we have
asadmin utility. But there is no obvious way to "reconfigure" existing network listener..
But here is a possible solution. Delete network listener and add another one! Here is a code sample changing existing default network listener with new one on port 8081:
asadmin delete-network-listener http-listener-1 asadmin delete-protocol http-listener-1 asadmin create-http-listener --default-virtual-server server --listenerport 8081 --listeneraddress 0.0.0.0 http-listener-1
The first line deletes existing network listener. And the second line deletes associated protocol. And the last line creates another network listener on port 8081.