Oracle had claimed almost $9bn (£6.1bn) in damages, after saying that Google had infringed its copyright.
Google argued that it should be able to use Java for free under the "fair use" clause, which under US law allows some access to material without the permission of the rights holder.
The jury at the US District Court in San Francisco unanimously upheld that argument.
The verdict was hugely significant due to the prevalence of both Java and Android, which is now used in 80% of the world’s mobile devices.
Google described it as "a win for the Android ecosystem, for the Java programming community, and for software developers who rely on open and free programming languages to build innovative consumer products."
But Oracle said it would now appeal to the US Supreme Court.
The company’s lawyer, Dorian Daley, said: "We strongly believe that Google developed Android by illegally copying core Java technology to rush into the mobile device market.
"Oracle brought this lawsuit to put a stop to Google's illegal behaviour. We believe there are numerous grounds for appeal and we plan to bring this case back to the federal circuit on appeal."