Do I need to be connected to the internet to write and run Java programs?
No, once you've installed Java and your preferred IDE, you can write and run Java programs offline.