You can write a compiler that implements the Java Language Specification or write a JVM that implements the Java Virtual Machine specification, but when you officially want to call it "Java", you have to prove it is compatible by passing the tests of the TCK (technology compatibility kit) and pay for a license from Oracle.
Oracle doesn't make it easy for other parties to do this, though. Apache has their own implementation of the JVM (Apache Harmony) but previously Sun, now Oracle, is not cooperating in making the TCK available nor let Apache get a license, which has led to a lot of resentment between Apache and Oracle.
Long ago Microsoft had their own version of Java (that was indeed called "Java"). They tried to change it to make it Windows-specific, which Sun of course didn't like. There was a lawsuit, Microsoft lost, quit their own Java version and created .NET, which is a completely different thing that just happens to work a lot like how Java works...
The lawsuit about Android isn't based on this at all; Google isn't saying that Android is Java. That lawsuit is about patents; Oracle has patents on a number of ideas and concepts in their own JVM implementation and is claiming that Google is using the same patented ideas in Android without getting a patent license from Oracle.