A federal appeals court on Friday reversed a federal judge's ruling that Oracle's Java API's were not protected by copyright.

The debacle started when Google copied certain elements—names, declaration, and header lines—of the Java APIs in Android, and Oracle sued. A judge largely sided with Google in 2012, saying that the code in question could not be copyrighted.

"Because we conclude that the declaring code and the structure, sequence, and organization of the API packages are entitled to copyright protection, we reverse the district court’s copyrightability determination with instructions to reinstate the jury’s infringement finding as to the 37 Java packages," the US Appeals Court for the Federal Circuit ruled Friday.

Google, which said it was exploring its legal options, decried Friday's ruling. The Mountain View, CA-based media giant said the decision "sets a damaging precedent for computer science and software development."

Some legal experts said assigning copyright to the code, or API, that enables programs to talk to one another sets a dangerous precedent.

The purpose of copyright is to encourage creativity. But while software is copyrightable, assigning copyright to a method of accessing that work limits creativity, and gives too much control to a copyright holder over its works that are already in the stream of commerce.

As an analogy, consider a book, which is protected by copyright. Books don't come with conditions on who or where they can be read. The copyright on books generally prohibits them from being duplicated without permission.

However, Oracle and others view the matter quite different. In a statement, the Redwood City, CA-based company said Friday's decision "is a win for the entire software industry that relies on copyright protection to fuel innovation."

US District Judge William Alsup, in his 2012 ruling for Google, wrote that even though Google could have rearranged "the various methods under different groupings among the various classes and packages," the overall name tree is "a utilitarian and functional set of symbols, each to carry out a pre-assigned function... Duplication of the command structure is necessary for interoperability."

The judge compared the Application Programming Interfaces (APIs) to a library, with each package as a bookshelf, each class a book on the shelf, and each method a chapter out of a how-to book.

"As to the 37 packages, the Java and Android libraries are organized in the same basic way but all of the chapters in Android have been written with implementations different from Java but solving the same problems and providing the same functions." The declarations, or headers, "must be identical to carry out the given function," Alsup wrote.

About 97 percent of the source code in the API packages are different. It's only the 3 percent that overlaps that formed the heart of Oracle's copyright claim. That three percent included packages, methods, and class names.

Still, the appellate court's ruling left open the door that Google may not be monetarily liable for infringement. The appeals court sent the case back to Alsup to determine whether Google had a "fair use" right to infringe.

There's no clear answer as to what constitutes fair use, and it's decided on a case-by-case basis.

"The distinction between what is fair use and what is infringement in a particular case will not always be clear or easily defined. There is no specific number of words, lines, or notes that may safely be taken without permission. Acknowledging the source of the copyrighted material does not substitute for obtaining permission," the US Copyright Office says.

Google and digital rights groups argued that APIs should not be copyrightable because developers need them to produce interoperable programs.

"An API is dictated primarily by functional requirements, not creativity or aesthetics, even more so than the internal implementation of a piece of software. Copyright protects creative expression, not functionality," Mitch Stoltz, an Electronic Frontier Foundation attorney said in an e-mail. "Also, the purpose of an API is to enable two pieces of software to interact. While copyright may protect software against copying, it shouldn't prevent building new software that can interact with existing programs. That impedes creativity rather than strengthening it."

Oracle has spent many millions on its legal crusade against Google. The company scanned 15 million lines of Android code and found one nine-line function that had been copied from Java; that code is no longer in Android.

Following Judge Alsup's original ruling, Oracle vowed an appeal, saying it would support "the broader Java community" of more than 9 million developers.

Oracle predicted it would prevail even under a fair use analysis because it "is not intended to protect naked commercial exploitation of copyrighted material."