I am having some issues while trying to install java : "sudo apt install default-jre" on a VM instance :

I realized that my VM has no external ip address as my company wont allow it. I can ping the localhost on the VM but not www.google.com fro example so i figured the lack of external IP was the issue. Is there another way that i can install java on this VM? I just have a basic java code (not an app) that i want to try by running "java -jar myjarname.jar".
Any idea would be helpfull.
If your goal is to be able to download from the Internet, set up a NAT Gateway.
Cloud NAT overview
Another option is to set up a VPN to your corporate network which provides a route to the Internet.
Otherwise, you will need to upload files to your VM and install them manually.