2

I'm tossing around the idea of writing and publishing a book on the Amazon Kindle platform about Java or Python. The name of the book would be something like "Basic and Simple Programming with Java" or "Learn to code with Python".

I would probably start with a chapter on how to set up an IDE, and have the book cover the basics such as variables, strings, conditionals, etc. using code examples. A simple example would be like

String name = "Sally";

Python states that "Python is developed under an OSI-approved open source license, making it freely usable and distributable, even for commercial use", so I assume the answer is yes for Python.

Java seems more legally complicated and I can't find anywhere if writing and publishing a book using and citing Java code is legally allowed.

Am I allowed to commercially publish and use samples of different coding languages in a book?

7
  • 8
    You have probably seen 100s of other books published about Java and Python. While the existence of other works is not a proof of their legitimacy, it would be good to understand what exactly triggered your concern. A book or publication about a programming language is not the programming language itself, and citing code obviously depends on the license of that code and not the license of the programming language. Jan 24, 2023 at 7:41
  • 1
    @Brandin really, that's an answer. You want to write it up as one?
    – MadHatter
    Jan 24, 2023 at 12:13
  • 1
    @MadHatter If anything it's an answer only to the very specific statement "to use samples of different coding languages in a book" which needs to be clarified by the OP for the same reason as mentioned in the first comment by Martin_in_AUT. So probably it should be a question. Who wrote the code samples? And additionally to the first comment, why do you think you need a license/permission to write about Python, Java, etc.? So as of yet I don't think this commentary will make a good Answer yet. Feel free to delete the comments as desired.
    – Brandin
    Jan 24, 2023 at 12:58
  • @Brandin I agree; do feel free to explicitly ask that question, which I think is well worth asking. The answer-as-comment I have, regretfully, deleted.
    – MadHatter
    Jan 24, 2023 at 13:06
  • I guess my concerns stem arise since Java SE is owned by Oracle. If I'm writing a book about Java and making money off of it, I was wondering if it was a concern. However, it seems like I should be ok.blogs.oracle.com/java/post/free-java-license Jan 24, 2023 at 17:54

1 Answer 1

8

Writing a book about Java or Python is not a problem w.r.t. the licenses of the programming languages. The book will be your own copyright (if you write it yourself), and it will not depend on the license terms which (for example) Oracle provides for Java.

Whenever you have sample code, which you include in your book, you need to look at 3 cases:

  • if the code is trivial and simple (a no-brainer) like the line mentioned in your question, then nobody can claim copyright, no matter if you write it yourself or if this is copied from elsewhere
  • if the code is complex and you have written it yourself, then you can determine the license conditions. For example you could include it with the rest of the text of your book and state "all rights reserved", or you could keep it separate and state that "all code in this book, except when stated otherwise, is (C) < my name> and licensed under MIT license"
  • Whenever you use non-trivial code copied from 3rd parties you have to comply with the license terms of that code as provided by the original author.

I would recommend that you find other on-line publications of renowned publishers and check how it is done there and that you follow their example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.