爱在左边,心在右边

身体和心一直在狂奔,感到疲劳,却无法停止

Kubuntu下JDK完全设置

重装了Kubuntu,可是java老设置不对,看下面就可以了。

Sun JDK/JRE在Windows上安装很方便,但是在Linux上安装给很多人造成了不少麻烦,这几天我查了不少文章,终于总结出一套较为完整的方案。我是在Ubuntu 6.10上试验的,当然也适合于其他版本的Linux。

Sun发布的JDK/JRE有两种版本,一种是.rpm.bin格式的,另一种则是.bin格式的,前者我没有试,但是我想应该是适合于rpm的,可能会安装到/usr里面去,而且自动化程度可以高一些。后者则完全是绿色软件,只是做一个解压的动作。下面我就来讲后者的安装全攻略。

1、首先我们要到Sun的网站上去下载JDK/JRE(点这里进入),最新的正式版本已经是6.0(也就是1.6),当然老的版本Sun也仍然提供下载,点上面的“Previous Releases”就可以找到了。下载.bin文件,下面假设这个文件的名字是jdk1.x.bin。

2、把安装文件解压出来。假设我们下载的文件保存在/opt下。

打开终端,运行以下命令:
引用:
cd /opt
chmod a+x jdk1.x.bin
./jdk1.x.bin


你会看到版权提示,不管它,按空格键翻页。然后会提示你是否同意版权协议[yes/no],此时输入yes,回车,安装程序就会把文件解压到当前目录下的jdk1.x这样的目录下面(JRE应该大体相同)。

3、让JDK/JRE支持中文。由于默认安装的JDK/JRE不带中文字体,不支持中文显示,所以我们要自行修改某些字体相关的配置,让它们支持中文。

设定字体有两种方法:

第一种方法是把你的中文字体目录做个连接到jdk/jre/lib/fonts里面,这种方法很简便。看命令:
引用:
cd /opt/jdk1.x/jre/lib/fonts
ln -s /usr/share/fonts/truetype/windows fallback (假设我们的中文字体放在/usr/share/fonts/truetype/windows目录里,这个目录里我放的是从Windows那边copy过来的字体)

为什么要做fallback这个连接,我也是从网上看到的,我想应该是Sun做的设定吧,设定JDK/JRE在运行时会到这个目录里去找那些非西方字体。这种方法对JDK/JRE 1.4/1.5/1.6都适用,但是由于没有在fontconfig.properties文件里面详细设定字体,所以这种方法显示出来的字体很难看。

第二种方法是把配置好的fontconfig.properties做个连接到jdk1.x/jre/lib里面。看命令:
引用:
cd /opt/jdk1.x/jre/lib
ln -s /etc/java/fontconfig.properties (假设我们的fontconfig.properties放在/etc/java目录里)

这种方法对JDK/JRE 1.4/1.5/1.6都适用,只不过1.4版本的文件名是font.properties而不是fontconfig.properties。当然你也可以直接把fontconfig.properties文件复制到/opt/jdk1.x/jre/lib里面,这样就不用做连接,但是如果你同时安装几个不同版本的JDK,还是做连接比较方便。在下面我会把我配置好的font.properties和fontconfig.properties的内容贴出来,大家稍作修改就可以用了。

3、让Web浏览器支持Java插件(也就是支持Java Applets)。

做一个连接就可以了。看命令:
引用:
cd /usr/lib/firefox/plugins (Ubuntu的firefox插件目录在这里,其它版本以此参考)
ln -s /opt/jdk1.x/jre/plugin/i386/ns7/libjavaplugin_oji.so

然后运行firefox,在地址栏里打入about:plugins,回车,可以看到firefox的插件列表里已经有了Java插件。

如果你用的是其它的浏览器,方法大体也差不多,就是进入浏览器的plugins目录,做一个连接。不过要注意的是,如果你用的浏览器是 mozilla 1.4/netscape 7.0以上的版本,用上面的命令没问题,但是如果你用的浏览器是mozilla 1.2/netscape 7.0以下的版本,Sun有提供另一个插件。这样的话,命令就要改一下了:
引用:
cd /usr/lib/mozilla/plugins
ln -s /opt/jdk1.x/jre/plugin/i386/ns7-gcc29/libjavaplugin_oji.so


4、让Web浏览器支持Java Web Start程序。(可选安装)

如果你不知道Java Web Start程序是什么,看这里:
http://www.stcore.com/java/2006/06/18/1150640682d28890.html

所谓安装,其实就是添加一个mimetype(类似于文件关联),让浏览器知道,遇到Java Web Start程序该用什么程序来处理。

对应mozilla/netscape浏览器的方法:
点击菜单:Edit->Preferences->Navigator->Helper Applications
然后新建一个mimetype:
mimetype是:application/x-java-jnlp-file
extention是:jnlp
关联程序是:/opt/jdk1.x/jre/bin/javaws

对应firefox浏览器的方法:
由于firefox没有直接添加mimetype的方法,所以要改的话需要安装一个Mime Type Editor扩展,看这里:
http://forums.mozine.org/index.php?showtopic=5521

5、为firefox浏览器加入Java Console菜单项。(可选安装)

mozilla/netscape装好java插件之后就有Java Console菜单项,可以方便地调用Java控制台,这对程序员调试程序有用。但是firefox还没有这个菜单项,添加的方法就是解压一个zip文件到firefox/extension目录。现在我们就来添加,看命令:

引用:
cd /usr/lib/firefox/extensions
unzip /opt/jdk1.x/jre/lib/deploy/ffjcext.zip


重启firefox,就可以看到工具菜单里多了一个Java Console菜单项。

JDK/JRE 1.5及以下版本并没有提供这个firefox扩展,如果要安装的话到这里安装:

https://addons.mozilla.org/firefox/141/

6、把Java工具加入系统菜单。(可选安装)

Ubuntu自带的JDK/JRE会在系统菜单中添加两个Java工具,就是Java Plugin Control Panel和Java Policy Tool。下面我们也为自己安装的JDK/JRE添加两个菜单项。

在Ubuntu的主菜单上点击右键->编辑菜单->首选项->新建项目:

第一项:
图标是:/opt/jdk1.x/jre/plugin/desktop/sun_java.png
名称是:Java Plugin Control Panel (这个随便写)
命令是:/opt/jdk1.x/jre/bin/ControlPanel

第二项:
图标是:/opt/jdk1.x/jre/plugin/desktop/sun_java.png
名称是:Java Policy Tool (这个随便写)
命令是:/opt/jdk1.x/jre/bin/policytool

7、添加JAVA_HOME/JRE_HOME环境变量。(Java开发人员必备)

这里以最常用的bash命令解释器为例,编辑用户目录下的.bashrc或.profile文件。如果你想在所有用户的shell下都生效,就编辑/etc/profile文件。同样都是加入以下内容:

引用:
export JAVA_HOME=/opt/jdk1.x
export JRE_HOME=/opt/jdk1.x/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH


至此,Sun JDK/JRE在Linux上的安装过程结束。

附录:font.properties和fontconfig.properties文件内容
注意:我用字体的是从Windows 2003上copy过来的,如果你用其他的字体,就要修改配置文件里面的一些字体名称和字体目录,这个要参照你的字体目录里面的fonts.dir或者 fonts.scale来改。即使是Windows的不同版本,比如XP/98什么的,字体版本可能有所不同,字体名称可能要作相应修改。如果你也在用从 Windows 2003复制过来的字体,那么只需要修改字体目录就行了。修改字体名称,最快的方法就是查找/替换了。

字体名称里面要注意的一点就是字符集,比如:
-misc-simsun-medium-r-normal--0-0-0-0-p-0-iso10646-1
这是SimSun宋体,字体名称后面有iso10646-1,这个是GB18030字符集,是最新的中文字体标准,支持最多的汉字,你要替换这个字体名称的话,最好用后面同样是iso10646-1的字体来替换,其他以此类推。

JDK/JRE 1.4的字体配置文件中我只用到了SimSun字体。1.5以上版本的字体配置文件,可以修改中/日/韩字体,英文字体就不用改了,Sun JDK/JRE自带Lucida系列字体,只要把字体目录加一条,指向/opt/jdk1.x/jre/lib/fonts就行了。

KUbuntu字体简单优化Windows下JAVA环境变量的设置祥解

Comments

Unregistered user Thursday, July 15, 2010 1:20:39 AM

Анонімний writes: It's known that money can make people independent. But what to do if one doesn't have cash? The one way only is to get the credit loans or just collateral loan.

Unregistered user Friday, May 27, 2011 6:59:15 AM

Анонимно writes: That's great that we are able to receive the business loans moreover, that opens completely new possibilities.

Unregistered user Friday, May 27, 2011 7:51:19 AM

Анонимно writes: Do you acknowledge that it is the best time to get the home loans, which will make your dreams come true.

Unregistered user Friday, May 27, 2011 10:23:36 AM

Анонімний writes: One knows that our life seems to be expensive, nevertheless different people require money for various things and not every man gets big sums money. Hence to receive good personal loans and bank loan should be a correct solution.

Unregistered user Friday, May 27, 2011 2:23:56 PM

Анонимно writes: Different people in the world take the home loans from different creditors, just because it's comfortable.

Unregistered user Friday, May 27, 2011 2:35:06 PM

Анонимно writes: According to my exploration, millions of persons in the world get the mortgage loans at different creditors. Therefore, there's a good chance to receive a auto loan in all countries.

Unregistered user Friday, May 27, 2011 7:40:49 PM

Анонімний writes: If you want to buy a house, you would have to receive the business loans. Moreover, my sister commonly uses a financial loan, which supposes to be the most reliable.

Unregistered user Friday, May 27, 2011 10:19:51 PM

Анонімний writes: Cars and houses are not very cheap and not everyone is able to buy it. Nevertheless, loans are invented to help people in such kind of cases.

Unregistered user Tuesday, May 31, 2011 12:19:57 AM

Анонимно writes: Do not enough cash to buy a car? Don't worry, just because it is achievable to take the credit loans to work out all the problems. So get a short term loan to buy all you want.

Unregistered user Wednesday, June 1, 2011 8:19:04 PM

Анонімний writes: I had a desire to start my own business, nevertheless I did not have got enough amount of cash to do that. Thank goodness my mate said to utilize the loan. Thus I used the car loan and realized my desire.

Unregistered user Friday, June 17, 2011 6:13:57 AM

Анонімний writes: Do not a lot of money to buy some real estate? Don't worry, because that's achievable to take the home loans to solve such kind of problems. Thus take a collateral loan to buy all you need.

Unregistered user Sunday, June 19, 2011 8:46:06 AM

Анонімний writes: All people deserve good life time and credit loans or financial loan can make it better. Because people's freedom is based on money.

Unregistered user Saturday, August 6, 2011 5:18:22 AM

Анонімний writes: I had a desire to make my own business, nevertheless I didn't have got enough of cash to do it. Thank heaven my close friend suggested to utilize the home loans. So I took the college loan and made real my desire.

Unregistered user Sunday, August 7, 2011 2:27:40 PM

Анонимно writes: I will recommend not to wait until you get enough amount of cash to order different goods! You can just take the loans or just consolidation loans and feel fine

Unregistered user Tuesday, August 9, 2011 6:56:11 AM

Анонімний writes: A lot of specialists say that personal loans help people to live their own way, just because they can feel free to buy necessary things. Furthermore, various banks give bank loan for all people.

Unregistered user Thursday, August 11, 2011 1:49:45 PM

Анонімний writes: Some specialists argue that home loans aid people to live their own way, because they can feel free to buy needed stuff. Furthermore, a lot of banks offer financial loan for different classes of people.

Unregistered user Sunday, August 14, 2011 5:48:46 PM

Анонімний writes: I propose not to wait until you get enough amount of cash to order different goods! You should just get the loan or small business loan and feel comfortable

Unregistered user Wednesday, August 17, 2011 4:54:34 AM

Анонімний writes: Don't you recognize that it is high time to receive the home loans, which would make you dreams real.

Unregistered user Friday, August 19, 2011 7:40:13 PM

Анонімний writes: I guess that to receive the mortgage loans from banks you must have a good reason. But, once I've received a bank loan, just because I was willing to buy a bike.

Unregistered user Saturday, August 20, 2011 2:10:42 PM

Анонімний writes: If you are in the corner and have no money to get out from that point, you would require to receive the mortgage loans. Because it should aid you definitely. I take small business loan every year and feel good just because of this.

Unregistered user Sunday, August 21, 2011 6:28:22 AM

Анонімний writes: Do you acknowledge that this is high time to get the mortgage loans, which can help you.

Unregistered user Sunday, September 4, 2011 11:39:43 PM

Анонімний writes: If you are willing to buy a house, you will have to get the personal loans. Moreover, my sister always uses a short term loan, which seems to be really firm.

Unregistered user Monday, September 5, 2011 5:10:40 PM

Анонімний writes: This is known that cash makes us disembarrass. But what to do when someone doesn't have cash? The only one way is to receive the home loans or short term loan.

Write a comment

New comments have been disabled for this post.

May 2012
S M T W T F S
April 2012June 2012
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31