How To Install Java on Ubuntu with Apt-Get

作者:Rui 发布时间:September 17, 2015 分类:JAVA,CLOUD 浏览:447

Installing Oracle JDK

The Oracle JDK is the official JDK; however, it is no longer provided by Oracle as a default installation for Ubuntu.

You can still install it using apt-get. To install any version, first execute the following commands:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

Then, depending on the version you want to install, execute one of the following commands:

Oracle JDK 6

This is an old version but still in use.

sudo apt-get install oracle-java6-installer

Oracle JDK 7

This is the latest stable version.

sudo apt-get install oracle-java7-installer

Oracle JDK 8

This is a developer preview, the general release is scheduled for March 2014. This external article about Java 8 may help you to understand what it's all about.

sudo apt-get install oracle-java8-installer

Ubuntu 12.04 LTS 中文输入法的安装

作者:Rui 发布时间:September 9, 2015 分类:Linux,CLOUD 浏览:587

安装 Ubuntu 12.04 着实费力一番功夫,老是在用 Ubuntu 来引导 Windows,结果 Ubuntu 倒是能用,一进入 Windows 就蓝屏,于是又重装 Windows 好几遍…直到后来认识了 EasyBCD 我才走上正途…

我装的是英文版的 Ubuntu12.04,如果安装中文版,会自动安装中文输入法,这篇文章也是为了以后重装 Ubuntu 做一个准备

废话不多说,进入正题:

第一步:安装语言包

进入 “System Settings”

1.png

找到 “Language Support” 那一项,点击进入
1.png

阅读剩余部分...

Ubuntu 14.04 国内更新源

作者:Rui 发布时间:September 9, 2015 分类:Linux,CLOUD 浏览:807

1、备份源

# sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2、编辑源文件/etc/apt/sources.list,并添加以下地址

# sudo gedit /etc/apt/sources.list

网易163源:

deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse 

搜狐源:

deb http://mirrors.sohu.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ trusty-backports main restricted universe multiverse

oschina源:

deb http://mirrors.oschina.net/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.oschina.net/ubuntu/ trusty-backports main restricted universe multiverse
deb http://mirrors.oschina.net/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.oschina.net/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.oschina.net/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.oschina.net/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.oschina.net/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.oschina.net/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.oschina.net/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.oschina.net/ubuntu/ trusty-updates main restricted universe multiverse

3、 更新源索引,使新源生效

# sudo apt-get update

4、其他版本的源
只要将trusty 换成相应的版本的代号即可

更多国内源请参考:

http://wiki.ubuntu.org.cn/%E6%BA%90%E5%88%97%E8%A1%A8#Precise.2812.04.29.E7.89.88.E6.9C.AC

Git中reset与revert的使用

作者:Rui 发布时间:September 9, 2015 分类: 浏览:547

1. reset(版本撤回)

格式:

git reset [-q] [<commit>] [--] <paths>... 
git reset (--patch | -p) [<commit>] [--] [<paths>...] 
git reset (--soft | --mixed | --hard | --merge | --keep) [-q] [<commit>]

用法:
git reset --mixed 回退commit,保留源码,默认方式.
git reset --soft 回退至某个版本,只回退commit信息
git reset --hard 彻底回退至某个版本
回退所有内容到上一个版本 git reset HEAD^
回退a.py这个文件的版本到上一个版本 git reset HEAD^ a.py
向前回退到第3个版本 git reset –soft HEAD~3
将本地的状态回退到和远程的一样 git reset –hard origin/master
回退到某个版本 git reset 057d
回退到上一次提交的状态,按照某一次的commit完全反向的进行一次commit git revert HEAD

2. revert(撤销操作)

撤销某次操作,此次操作之前的commit都会被保留. git reset 是撤销某次提交,但是此次之后的修改都会被退回到暂存区.

阅读剩余部分...

Hibernate JPA 联合主键

作者:Rui 发布时间:September 9, 2015 分类:JAVA,Hibernate 浏览:726

两个或多个字段组成的主键,我们叫联合主键,在JPA中定义联合主键需要单独定义一个主键类来表示联合主键。

下面是定义一个主键类:

public class UserRolePk implements Serializable {
    public User user;
 
    public Role role;
 
    public UserRolePk() {}
 
    public int hashCode() {
        return (this.user.id + "_" + this.role.id).hashCode();
    }
 
    public boolean equals(UserRolePk userRolePk) {
        return this.user.equals(userRolePk.user) && this.role.equals(userRolePk.role);
    }
}

阅读剩余部分...