這里使用LGPL協(xié)議為例簡單說明一下如何將自己的程序宣告為開源軟件
首先確定自己要使用的開源協(xié)議,這里選擇LGPL(關(guān)于其它協(xié)議及協(xié)議的詳細內(nèi)容,請參考其它資料),
然后確定并準(zhǔn)備以下幾部分內(nèi)容:
- 一份版權(quán)信息聲明文件,一般命名為"NOTICE"
- 一份所使用的協(xié)議的副本.
- 如果程序為多個文件構(gòu)成,則在每個文件中包含文件頭信息,聲明協(xié)議及版權(quán)信息
一般來說主要就是由以上幾部分組成,下面簡單說明一下相關(guān)組成部分。
1.首先,對于版權(quán)信息聲明文件,我們可以寫一份文本文檔,一般命名為NOTICE, 其中包含版權(quán)聲明及一些自己想要聲明的信息,示例如:
Copyright 1998, 1999 Terry Jones
用于聲明軟件的發(fā)布年份及作者姓名,一般建議分別列出每個年份,不一定需要符號©, 最簡單的NOTICE,包含這些內(nèi)容就可以了。
但是一般建議應(yīng)該包含以下一些信息:
a) 軟件作者聯(lián)系信息,用于在必要時聯(lián)系作者
b) 獲取軟件源碼的地址,當(dāng)發(fā)布為二進制時,可以告訴用戶在那里可以獲得軟件的源碼。
c) 其它開源組件庫的開源協(xié)議及源碼地址,如果你所分發(fā)的軟件使用了其它開源產(chǎn)品,則應(yīng)該同時包含他們的開源協(xié)議以及相應(yīng)的源碼地址。
2. 一份軟件的使用協(xié)議,這里我們使用LGPL(GNU Lesser General Public License)為例說明.
我們需要在(一般為軟件所在的根目錄下)包含這兩個文件:
a) 一份GPL的協(xié)議副本,一般命名為COPYING, 你可以從這里獲得相關(guān)的協(xié)議副本
http://www.gnu.org/licenses/gpl.txt
b) 一份LGPL協(xié)議副本,一般命名為COPYING.LESSER, 可以從這里獲得相關(guān)的協(xié)議副本
http://www.gnu.org/licenses/lgpl.txt
如果軟件發(fā)布在GPL下,則只需要一份GPL協(xié)議副本就可以,如果為LGPL則應(yīng)該同時包含GPL及LGPL兩個協(xié)議副本。
3.如果程序為多個文件源文件構(gòu)成,則在每個文件中包含文件頭信息,聲明協(xié)議及版權(quán)信息.
來自gnu.org的示例文本如下:
This file is part of Foobar.
Foobar is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Foobar is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
上面是以LGPL為例說明的. 更詳細的信息可以參考這里 http://www.gnu.org/licenses/gpl-howto.html
下面是我的使用示例,以下信息僅供參考:

NOTICE文件如下
01 /*
02 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
03 *
04 * Copyright 2010 huliqing, huliqing.cn@gmail.com
05 *
06 *
07 * QBlog is free software: you can redistribute it and/or modify
08 * it under the terms of the GNU Lesser General Public License as published by
09 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * QBlog is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with QBlog. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * QBlog是一個自由軟件,您可以自由分發(fā)、修改其中的源代碼或者重新發(fā)布它,
21 * 新的任何修改后的重新發(fā)布版必須同樣在遵守LGPL3或更后續(xù)的版本協(xié)議下發(fā)布.
22 * 關(guān)于LGPL協(xié)議的細則請參考COPYING、COPYING.LESSER文件,
23 * 您可以在QBlog的相關(guān)目錄中獲得LGPL協(xié)議的副本,
24 * 如果沒有找到,請連接到 http://www.gnu.org/licenses/ 查看。
25 *
26 * - Author: Huliqing
27 * - Contact: huliqing.cn@gmail.com
28 * - License: GNU Lesser General Public License (LGPL)
29 * - Blog and source code availability: http://www.huliqing.name/
30 */
31
32
33 LICENSE INFORMATION REGARDING BUNDLED THIRD-PARTY SOFTWARE
34
35
36
37 The following third party software is distributed with the QBlog and is provided
38 under other
39 licenses and/or has source available from other locations.
40
41 * JSF Frameworker
42 License: CDDLv.1.0 + GPL v.2.0
43 Source code availability: https://javaserverfaces.dev.java.net/
44
45 lib/jsf-api.jar
46 lib/jsf-impl.jar
47
48 * Jakarta Taglibs
49
50 License: Apache License v. 2.0
51
52 Source code availability: http://jakarta.apache.org/taglibs/
53 lib/standard-1.1.2.jar
54
55 lib/jstl-1.1.2.jar
56
57 * DataNucleus Access Platform
58
59 License: Apache License v. 2.0
60
61 Source code availability: http://www.datanucleus.org/
62
63 lib/datanucleus-core-1.1.5.jar
64
65 lib/datanucleus-jpa-1.1.5.jar
66
67
68 * Xml
69 License: Apache License v. 2.0
70
71 Apache Software Foundation (http://xml.apache.org/commons)
72 David Megginson, Simple API for XML (http://www.saxproject.org)
73 World Wide Web Consortium, xml-commons for http://xml.apache.org/ subproject (http://www.w3c.org/DOM)
74 Sun Microsystems Inc., JSR 206, Java API for XML Processing 1.3(http://java.sun.com/xml/jaxp.html)
75 lib/xml-apis.jar
76 lib/xalan.jar
77 lib/xsltc.jar
78 lib/serializer.jar
79 lib/xercesImpl.jar
80
81 * el
82 JSP 2.1's EL API, as used by JSF 2.0
83 SUN (http://java.sun.com/products/jsp)
84 lib/el-api-1.1.jar
85 lib/el-impl-1.1.jar
86
87 * QFaces
88 License: LGPL v. 3.0
89 Source code availability: http://www.huliqing.name/
90 lib/qfaces-2.0.2.jar
91
92 * huliqing-common
93 No license and no source code, free use.
94 lib/huliqing-common-1.1.jar
95
96
97
98
文件頭信息參考如下:
01 /*
02 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
03 *
04 * Copyright 2010 huliqing, huliqing.cn@gmail.com
05 *
06 * This file is part of QBlog.
07 * QBlog is free software: you can redistribute it and/or modify
08 * it under the terms of the GNU Lesser General Public License as published by
09 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * QBlog is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with QBlog. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * 這個文件是QBlog的一部分。
21 * 您可以單獨使用或分發(fā)這個文件,但請不要移除這個頭部聲明信息.
22 * QBlog是一個自由軟件,您可以自由分發(fā)、修改其中的源代碼或者重新發(fā)布它,
23 * 新的任何修改后的重新發(fā)布版必須同樣在遵守LGPL3或更后續(xù)的版本協(xié)議下發(fā)布.
24 * 關(guān)于LGPL協(xié)議的細則請參考COPYING、COPYING.LESSER文件,
25 * 您可以在QBlog的相關(guān)目錄中獲得LGPL協(xié)議的副本,
26 * 如果沒有找到,請連接到 http://www.gnu.org/licenses/ 查看。
27 *
28 * - Author: Huliqing
29 * - Contact: huliqing.cn@gmail.com
30 * - License: GNU Lesser General Public License (LGPL)
31 * - Blog and source code availability: http://www.huliqing.name/
32 */
33
34 package name.huliqing.qblog;
35
36 import java.text.SimpleDateFormat;
37 import java.util.Date;
38 import java.util.TimeZone;
39 import java.util.logging.Logger;
40 import javax.servlet.ServletContextEvent;
41 import javax.servlet.ServletContextListener;
42 import name.huliqing.qblog.service.MailSe;
43
-44 public class ContextListener implements ServletContextListener {
45 private final static Logger logger = Logger.getLogger(ContextListener.class.getName());
46
-47 public void contextDestroyed(ServletContextEvent arg0) {
48 logger.info("QBlog Shutdown");
49 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
50 sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
51 MailSe.sendToSelf("QBlog shutdown at:" + sdf.format(new Date()), "QBlog shutdown.");
52 }
53
-54 public void contextInitialized(ServletContextEvent arg0) {
55 logger.info("QBlog Start...");
56 }
57
58 }
59