100% found this document useful (17 votes)
54 views

JRuby Cookbook 1st Edition Edelson 2024 Scribd Download

JRuby

Uploaded by

ubertkralyx1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (17 votes)
54 views

JRuby Cookbook 1st Edition Edelson 2024 Scribd Download

JRuby

Uploaded by

ubertkralyx1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Download the full version of the ebook at ebookname.

com

JRuby Cookbook 1st Edition Edelson

https://ebookname.com/product/jruby-cookbook-1st-edition-
edelson/

OR CLICK BUTTON

DOWNLOAD EBOOK

Download more ebook instantly today at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Elixir Cookbook 1st Edition Pereira

https://ebookname.com/product/elixir-cookbook-1st-edition-pereira/

ebookname.com

PHP Cookbook 1st Edition David Sklar

https://ebookname.com/product/php-cookbook-1st-edition-david-sklar/

ebookname.com

Asterisk Cookbook 1st Edition Leif Madsen

https://ebookname.com/product/asterisk-cookbook-1st-edition-leif-
madsen/

ebookname.com

John Woo The Films 2nd Edition Kenneth E. Hall

https://ebookname.com/product/john-woo-the-films-2nd-edition-kenneth-
e-hall/

ebookname.com
Dance Research Methodologies 1 Edition Rosemary
Candelario

https://ebookname.com/product/dance-research-methodologies-1-edition-
rosemary-candelario/

ebookname.com

Politeness through the Prism of Requests Apologies and


Refusals A Case of Advanced Serbian EFL Learners 1st
Edition Milica Savic
https://ebookname.com/product/politeness-through-the-prism-of-
requests-apologies-and-refusals-a-case-of-advanced-serbian-efl-
learners-1st-edition-milica-savic/
ebookname.com

The SAGE Handbook of Environment and Society 1st Edition


Jules Pretty Et Al. (Eds.)

https://ebookname.com/product/the-sage-handbook-of-environment-and-
society-1st-edition-jules-pretty-et-al-eds/

ebookname.com

New York City For Dummies 5th Edition Myka Carroll

https://ebookname.com/product/new-york-city-for-dummies-5th-edition-
myka-carroll/

ebookname.com

Advances in Heat Transfer 44 1st Edition Ephraim M.


Sparrow

https://ebookname.com/product/advances-in-heat-transfer-44-1st-
edition-ephraim-m-sparrow/

ebookname.com
The Oceanic Languages John Lynch

https://ebookname.com/product/the-oceanic-languages-john-lynch/

ebookname.com
www.allitebooks.com
www.allitebooks.com
JRuby Cookbook ™

Justin Edelson and Henry Liu

Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo

www.allitebooks.com
JRuby Cookbook™
by Justin Edelson and Henry Liu

Copyright © 2009 Justin Edelson and Henry Liu. All rights reserved.
Printed in the United States of America.

Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.

O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (http://safari.oreilly.com). For more information, contact our corporate/
institutional sales department: 800-998-9938 or corporate@oreilly.com.

Editor: Mike Loukides Indexer: Ellen Troutman Zaig


Production Editor: Sarah Schneider Cover Designer: Karen Montgomery
Copyeditor: Colleen Gorman Interior Designer: David Futato
Proofreader: Kiel Van Horn Illustrator: Jessamyn Read

Printing History:
November 2008: First Edition.

O’Reilly and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. JRuby Cookbook, the
image of an African civet, and related trade dress are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a
trademark claim, the designations have been printed in caps or initial caps.

While every precaution has been taken in the preparation of this book, the publisher and authors assume
no responsibility for errors or omissions, or for damages resulting from the use of the information con-
tained herein.

ISBN: 978-0-596-51980-3

[M]

1225300397

www.allitebooks.com
Table of Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii

1. Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Installing JRuby 4
1.2 Managing Packages with RubyGems 8
1.3 Using Both Ruby and JRuby 9
1.4 Sharing RubyGems 11
1.5 Referencing Java Classes from Ruby 12
1.6 Converting a Ruby Array into a Java Array 15
1.7 Adding JAR Files to the Classpath 16
1.8 Extending a Java Class in Ruby 17
1.9 Implementing a Java Interface in Ruby 18
1.10 Opening Java Classes with JRuby 22
1.11 Setting Up Eclipse for JRuby Development 24
1.12 Setting Up NetBeans for JRuby Development 28
1.13 Platform Detection in a JRuby Application 31

2. JRuby on Rails . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.1 Installing and Setting Up Rails 34
2.2 Packaging Rails As a Java EE Web Application 37
2.3 Using an External Gem Repository with a Web Application 39
2.4 Configuring the JRuby-Rack Servlet 39
2.5 Packaging Rails with a JNDI DataSource 41
2.6 Deploying Rails on Tomcat 42
2.7 Deploying Rails on JBoss 44
2.8 Deploying Rails on Jetty 46
2.9 Deploying Rails with jetty_rails 47
2.10 Deploying Rails with Mongrel 49
2.11 Deploying Rails on the GlassFish v2 Server 51
2.12 Using the GlassFish v3 Gem 52
2.13 Using ActiveRecord Outside of Rails 53
2.14 Accessing Common Java Servlet Information 55

iii

www.allitebooks.com
2.15 Configuring Session Storage 56
2.16 Controlling the Classes, Directories, and Other Files Packaged into
a Rails WAR File 57
2.17 Changing the Name of the WAR File and the Staging Area 58
2.18 Deploying a Rails Application to the Root Context 58
2.19 Creating a Rails Application with Aptana Studio 60
2.20 Accessing Static Files in Your Rails Java EE Application 63

3. Java Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.1 Executing Ruby from Java 66
3.2 Invoking JRuby Through the Bean Scripting Framework 70
3.3 Invoking JRuby Through Java Scripting Support 72
3.4 Logging from Ruby with Jakarta Commons Logging 75
3.5 Using the Java Concurrency Utilities 77
3.6 Creating JavaBean Style Accessor Methods 79
3.7 Writing Consistent Code 80
3.8 Transforming XML with TrAX 80
3.9 Creating a Pool of JRuby Runtimes 82
3.10 Performing Remote Management with JMX 84
3.11 Accessing Native Libraries with JRuby 86

4. Enterprise Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
4.1 Creating a JNDI Context 90
4.2 Sending JMS Messages 92
4.3 Receiving JMS Messages 95
4.4 Implementing an Enterprise JavaBean with JRuby 96
4.5 Defining Spring Beans in JRuby 100
4.6 Creating Refreshable JRuby Spring Beans 103
4.7 Defining JRuby Spring Beans Inline 106
4.8 Applying Spring-Aware Interfaces to JRuby Objects 107
4.9 Creating Spring MVC Controllers with JRuby 110
4.10 Using Hibernate with JRuby 113
4.11 Using the Java Persistence API with JRuby 115
4.12 Making SOAP Calls 116
4.13 Simplifying LDAP Access 118

5. User Interface and Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121


5.1 Creating Swing Applications 122
5.2 Swing Event Handling 123
5.3 Long-Running Tasks in Swing Applications 124
5.4 Packaging Standalone Applications 126
5.5 Packaging JRuby Web Start Applications 128
5.6 Creating JRuby Applets 130

iv | Table of Contents

www.allitebooks.com
5.7 Manipulating Images 133
5.8 Creating SWT Applications 136
5.9 Accessing the Native Desktop 138
5.10 Accessing the System Tray 139
5.11 Swing Development with JRuby Domain-Specific Languages 141
5.12 Using the Monkeybars Framework for Swing Development 144
5.13 Creating Qt Applications with JRuby 148

6. Build Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153


6.1 Adding Ruby Scripting to Ant Builds 154
6.2 Using Ruby in Ant Conditions 156
6.3 Writing an Ant Task in Ruby 158
6.4 Adding Ruby Scripting to Maven Builds 158
6.5 Writing a Maven Plugin with JRuby 161
6.6 Building Java Projects with Raven 164
6.7 Referencing Libraries with Raven 165
6.8 Hosting a Private Raven Repository 166
6.9 Running JUnit Tests with Raven 167
6.10 Building Java Projects with Buildr 168
6.11 Referencing Libraries with Buildr 171
6.12 Building with Rake Inside Hudson 172
6.13 Adding Ruby Script to a Hudson Job 173

7. Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
7.1 Unit Testing Java Code with Test/Unit 176
7.2 Unit Testing Java Code with dust 178
7.3 Unit Testing Java Code with Expectations 179
7.4 Testing Java Code with RSpec 181
7.5 Creating Mock Objects with Mocha 185
7.6 Modifying the JtestR Classpath 187
7.7 Grouping Tests for JtestR 188
7.8 Using the JtestR Command-Line Options 188
7.9 Running JtestR with Ant 190
7.10 Running JtestR with Maven 190
7.11 Improving JtestR Performance 192

8. The JRuby Community . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195


8.1 Building JRuby from Source 195
8.2 Submitting an Issue Report for JRuby 196
8.3 Using the JRuby Mailing Lists 198

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

Table of Contents | v

www.allitebooks.com
www.allitebooks.com
Preface

JRuby is just Ruby taking advantage of Java’s VM;


taking the suck out of Java and putting some extra
awesome into Ruby.
—Charles Nutter, JRuby project lead
Twitter, August 7, 2008

And with that quote, Charles Nutter summarizes the two forces that have recently
brought attention to the JRuby project: the recognition that Java provides a powerful
platform that can be used by languages other than Java, and the increase in interest in
the Ruby programming language. In the recipes ahead, we will explore a wide variety
of usage scenarios for JRuby. In Charles’s terms, some recipes are about taking the suck
out of Java, some are about putting some extra awesome into Ruby, and some are about
both.

Audience
To fully leverage JRuby, you must be able to move freely between the Java and Ruby
domains. In writing the JRuby Cookbook, we had in mind a reader with some under-
standing of both languages, possibly with a better understanding of one or the other.
As a result, you won’t find a lot of basic introductory material, save for the first chapter
where we illustrate the areas where Ruby and Java are similar as well as where they
differ.
Our overall approach is that the purpose of the recipes in this book is not to educate
you on some preexisting Java or Ruby capability, but instead to explain how to use
JRuby within the context of, or as an enhancement to, these existing capabilities. For
example, the recipes in the JRuby on Rails chapter are written for someone who has
already created a (working) Rails application.

vii

www.allitebooks.com
Organization
Chapter 1, Getting Started
This chapter starts off with a brief introduction to JRuby before stepping through
a number of basic usages of JRuby, including how to use the RubyGems package
management system and how to interact with Java code from Ruby code. The
package concludes with a number of recipes about setting up various integrated
development environments (IDEs) for working with JRuby.
Chapter 2, JRuby on Rails
This chapter is focused on a variety of scenarios for deploying Ruby on Rails
applications using JRuby.
Chapter 3, Java Integration
This chapter starts with several recipes about invoking Ruby code from Java code
and then continues into recipes describing the usage of popular Java libraries such
as Java Native Access (JNA) and Jakarta Commons Logging from Ruby.
Chapter 4, Enterprise Java
The recipes in this chapter are all about using JRuby with enterprise Java frame-
works such as JMS, JNDI, EJB, Spring, and Hibernate.
Chapter 5, User Interface and Graphics
This chapter describes a number of JRuby-based frameworks that facilitate the
creation of user interfaces. It also includes recipes about image manipulation,
applets, and desktop integration.
Chapter 6, Build Tools
The recipes in this chapter are focused on using JRuby to enhance the build process
of your Java project. Ant and Maven, the two most popular Java-based build tools,
both have several different ways that JRuby can be used. There are also recipes
about the JRuby-specific build tools Raven and Buildr.
Chapter 7, Testing
The focus of this chapter is on JtestR, a package that includes JRuby and a variety
of popular Ruby testing tools. Through the recipes in this chapter, you will learn
how to write Ruby-based tests of Java code.
Chapter 8, The JRuby Community
This final chapter includes a few recipes about effectively participating in the JRuby
community.

Conventions Used in This Book


This book uses the following typographic conventions:
Italic
Used for example URLs, names of directories and files, options, and occasionally
for emphasis.

viii | Preface

www.allitebooks.com
Constant width
Used for program listings. Also used within paragraphs to refer to program
elements such as namespaces, classes, and method names.
Constant width italic
Indicates text that should be replaced with user-supplied values.

This icon indicates a tip, suggestion, or general note.

This icon indicates a warning or caution.

Using Code Examples


This book is here to help you get your job done. In general, you may use the code in
this book in your programs and documentation. You do not need to contact us for
permission unless you’re reproducing a significant portion of the code. For example,
writing a program that uses several chunks of code from this book does not require
permission. Selling or distributing a CD-ROM of examples from O’Reilly books does
require permission. Answering a question by citing this book and quoting example
code does not require permission. Incorporating a significant amount of example code
from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title,
author, publisher, and ISBN. For example: “JRuby Cookbook, by Justin Edelson and
Henry Liu. Copyright 2009 Justin Edelson and Henry Liu, 978-0-596-51980-3.”
If you feel your use of code examples falls outside fair use or the permission given above,
feel free to contact us at permissions@oreilly.com.

Safari® Books Online


When you see a Safari® Books Online icon on the cover of your favorite
technology book, that means the book is available online through the
O’Reilly Network Safari Bookshelf.
Safari offers a solution that’s better than e-books. It’s a virtual library that lets you easily
search thousands of top tech books, cut and paste code samples, download chapters,
and find quick answers when you need the most accurate, current information. Try it
for free at http://safari.oreilly.com.

Preface | ix
Comments and Questions
We at O’Reilly have tested and verified the information in this book to the best of our
ability, but mistakes and oversights do occur. Please let us know about errors you may
find, as well as your suggestions for future editions, by writing to:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the U.S. or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)
To ask technical questions or comment on the book, send email to:
bookquestions@oreilly.com
We have a website for this book where examples, errata, and any plans for future edi-
tions are listed. You can access this site at:
http://www.oreilly.com/catalog/9780596519803
For more information about this book and others, see the O’Reilly website:
http://www.oreilly.com

Acknowledgments
Thanks to the O’Reilly staff, especially our editor Mike Loukides and copyeditor Col-
leen Gorman. Thanks to Steven Shingler for his contribution to Chapter 4. And thanks
to all who reviewed this book including Juan Pablo Tarquino, John Purcell, and David
Koontz.
This book simply would not and could not exist without the tireless efforts of the whole
JRuby project team, including Charles Nutter, Thomas Enebo, Nick Sieger, and Ola
Bini. Thanks also to Sun and ThoughtWorks for their ongoing support of JRuby. The
JRuby project is hosted by The Codehaus; thanks as well to Bob McWhirter for his
work there.
We both would like to thank Nick Rockwell for his ongoing encouragement and
enthusiasm.

Justin Edelson
This book wouldn’t have happened without the love and support of my wonderful wife,
Elizabeth. Special thanks to my sons: Owen, who typed his name all by himself, and
Benjamin, who can’t yet.

x | Preface
Thanks to my team at MTV Networks: Michael Benoit, Keith Griffin, Ramesh Nutha-
lapati, Ilya Reznikov, Chris Sindel, Jeff Yemin, and Jun Zhou, for all their hard work.
Thanks also to Warren Habib for his support.

Henry Liu
Thanks to my friend Jon Baer for inviting me to my first Ruby meeting and being a great
collaborator throughout the years. I’m grateful to Francis Hwang, Matt Pelletier,
Sebastian Delmont, Trotter Cashion, and all the members of the NYC Ruby group.
They taught me Ruby and Rails by answering all my newbie questions, and it was their
passion and enthusiasm for the technology that motivated me to dig deeper. Thanks
to all my colleagues at MTV Networks and specifically Mark Ache, Luke Murphy, and
Steve Azueta for their continued support. Most of all, thanks to my family and my
partner, Naomi; without her, none of this would be possible.

Preface | xi
CHAPTER 1
Getting Started

1.0 Introduction
JRuby is an open source implementation of the Ruby programming language for the
Java Virtual Machine (JVM). It allows Ruby applications to be run within a Java Virtual
Machine and interface with libraries written in either Java or Ruby. Although the JRuby
project was initiated in 2001, interest in JRuby has grown significantly over the last few
years, reflecting an overall growth in interest in Ruby sparked by the success of the
Ruby on Rails framework. Sun has contributed to JRuby’s success by employing mem-
bers of the core development team and providing support for JRuby in the NetBeans
development environment, among other efforts. The website for the JRuby project is
currently http://www.jruby.org.

Ruby
Ruby is a dynamic object-oriented programming language created by Yukihiro Mat-
sumoto, known by the nickname Matz, in the mid-1990s. Ruby follows a style of ver-
sioning similar to the Linux kernel, where an even minor version number indicates a
stable release and an odd minor version number indicates a development release. As a
result, there are two current versions of Ruby: 1.8.6, released in March 2007, is the
current stable release, and 1.9.0, released in December 2007, is the current development
release. The standard Ruby interpreter* is written in C. There are several alternate
implementations of the interpreter, including JRuby, IronRuby (for Microsoft’s .NET
framework), and Rubinius. Ruby does not have a formal language specification; how-
ever, one is being developed through the wiki at http://spec.ruby-doc.org.
As an object-orientated language, many of the underlying concepts of Ruby will be
familiar to Java developers, even if the syntax is not. The biggest exception to this is
Ruby’s support for blocks. In Ruby, a block is a grouping of code that gets passed to a
method call. The receiving method can invoke the block any number of times and can
pass parameters to the block. Support for a similar type of element, a closure, is being

* Usually referred to as Matz’s Ruby Interpreter (MRI).

1
Exploring the Variety of Random
Documents with Different Content
law in creating the Project Gutenberg™ collection. Despite these
efforts, Project Gutenberg™ electronic works, and the medium
on which they may be stored, may contain “Defects,” such as,
but not limited to, incomplete, inaccurate or corrupt data,
transcription errors, a copyright or other intellectual property
infringement, a defective or damaged disk or other medium, a
computer virus, or computer codes that damage or cannot be
read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU AGREE
THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT
LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT
EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE
THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person
or entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you
do or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status
by the Internal Revenue Service. The Foundation’s EIN or
federal tax identification number is 64-6221541. Contributions
to the Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact
Section 4. Information about Donations to
the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or determine
the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.

Please check the Project Gutenberg web pages for current


donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.

You might also like