Thursday, February 15, 2018

java: Invalid argument on unix

I was trying to install JDK on Solaris.

I installed JDK for Solaris X64 avoiding SPARC installation as I did not know what is SPARC ;-)

once installed, I was getting error :
java: Invalid argument 

Soon I found that this error comes if java installation is of wrong type.

Find your correct type of JDK by checking the system type by
uname -p

Process ID - PID of the used port in Solaris, Unix

In Unix/Linux PID of the port used can be found by

netstat --listen
OR
netstat -l
OR
netstat -aun
OR
netstat -an|grep LISTEN    will give you list of opened ports


Problem is with Solaris (10). There is no direct command to find the same.

I found following links to execute shell scripts:
https://blogs.oracle.com/opengrok/get-application-pid-listening-on-a-network-port-in-solaris-aka-netstat-npl-in-solaris

https://geekflare.com/check-pid-using-port-number-solaris/

But I could not executed any of these and finally found following:

PORT=19028; for PID in /proc/*; do pfiles ${PID} |grep "port: ${PORT}" && echo ${PID}; done

you may have to search for AF_INET

If you have ROOT permission, then you may find any port's PID else it can help you to find the port at least opened by you.