In general you can run OpenJDK. Some applications suggest using Oracle JRE in production - e.g. the recommended production settings for Apache Cassandra require this. If your applications aren’t running in production, you can fairly safely use OpenJDK or another free distribution of Java. As others have mentioned, it is prudent to make sure you’re adhering to Oracle’s licensing if you use their JRE.
Re: Java being closed source - there was a time when this was true, but the Java language is now fully open source, and OpenJDK (which is the reference implementation of Java) is released under GPLv2 (+classpath exception)