Forge for 1.18+ es quite different and requires some extra steps. This is how I did to install forge in mi AWS EC2 server running Ubuntu 20.04
First installed java 17 jdk and jre using:
$ sudo apt install openjdk-17-jre-headless
$ sudo apt install openjdk-17-jdk-headless
You can check what version you have installed with:
$ java -version
$ javac -version
Now for the installation of forge I first installed minecraft server vanilla to generate all the files. Then ran the installer:
$ sudo -jar forge-x.x.x-x.x.x-installer.jar --installServer
If you don't specify the installServer flag, it will try to run the installer using a GUI which will not work if you are connected through ssh to your server. If you are connected through any remote desk app you can run it without the flag.
The difference here is that it will NOT generate a forge-x.x.x-server.jar file, instead of that it will be a shell script called "run.sh". You run it like this:
$ sudo ./run.sh
Now your forge server is running!