转载:http://blog.csdn.net/kengmun/article/details/46674661
注意:一定要下载jdk-8u45-linux-x64或者jdk-8u45-linux-x32 的 jdk1.7是不行的
介绍一下我的环境,ubuntu 14.04LTS,安装的jdk为jdk-8u45-linux-x64,安装的pycharm为pycharm-professional-4.5.2
1. 下载最新的pycharm,地址http://www.jetbrains.com/pycharm/download/
2. 安装JDK.下载最新的JDK,地址http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2.1 解压安装
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">01.</span> sudo mkdir /usr/lib/jvm <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">02.</span> sudo tar zxvf jdk<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">-</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>u45<span class="hljs-attribute" style="box-sizing: border-box;">-linux</span><span class="hljs-attribute" style="box-sizing: border-box;">-x64</span><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>tar<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>gz <span class="hljs-attribute" style="box-sizing: border-box;">-C</span> /usr/lib/jvm </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>
改名操作
<code class="hljs markdown has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-bullet" style="box-sizing: border-box;">01. </span>cd /usr/lib/jvm <span class="hljs-bullet" style="box-sizing: border-box;">02. </span>mv jdk1.8.0_45 jdk1.8.0</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>
2.2 修改环境变量
<code class="hljs bash has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">01</span>. <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> gedit /etc/profile </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
将下面的内容添加进文本的末端,然后保存退出:
<code class="hljs bash has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">#set java environment</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">export</span> JAVA_HOME=/usr/lib/jvm/jdk1.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8.0</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">export</span> JRE_HOME=<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">${JAVA_HOME}</span>/jre <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">export</span> CLASSPATH=.:<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">${JAVA_HOME}</span>/lib:<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">${JRE_HOME}</span>/lib <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">export</span> PATH=<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">${JAVA_HOME}</span>/bin:<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$PATH</span> </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li></ul>
2.3 配置默认JDK版本
接下来,我们要将刚刚安装JDK设置为默认JDK版本。
<code class="hljs bash has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">01</span>. <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8.0</span>/bin/java <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">300</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">02</span>. <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8.0</span>/bin/javac <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">300</span> </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>
执行代码,目的是查看各种jdk版本,原来的openjdk应该已经被卸载掉了:
<code class="hljs bash has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">01</span>. <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> update-alternatives --config java </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
2.4 测试
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">01.</span> java <span class="hljs-attribute" style="box-sizing: border-box;">-version</span> (会显示如下信息,说明已配置成功) <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">02.</span> java version <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"1.8.0"</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">03.</span> Java(TM) SE Runtime Environment (build <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1.8</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span>_45<span class="hljs-attribute" style="box-sizing: border-box;">-b14</span>) <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">04.</span> Java HotSpot(TM) <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">64</span><span class="hljs-attribute" style="box-sizing: border-box;">-Bit</span> Server VM (build <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">25.45</span><span class="hljs-attribute" style="box-sizing: border-box;">-b02</span>, mixed mode)</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul>
3. 安装pycharm
3.1 建个保存pycharm的文件夹,将下载的安装包解压到该文件夹
<code class="hljs bash has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">01</span>. <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> mkdir /usr/lib/pycharm <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">02</span>. <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> tar zxvf pycharm-professional-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4.5</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span> -C /usr/lib/pycharm </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>
3.2 进入解压后的文件夹,找到bin文件夹下的pycharm.sh,运行它(注意:运行该命令不能在xshell下运行,不然会提示找不到图形库的,所以需要到ubuntu下启动终端运行)
<code class="hljs markdown has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-bullet" style="box-sizing: border-box;">01. </span>cd /usr/lib/pycharm/pycharm-4.5.2/bin <span class="hljs-bullet" style="box-sizing: border-box;">02. </span>sh pycharm.sh</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>
3.3 输入注册码:
user name: EMBRACE
key:
14203-12042010
0000107Iq75C621P7X1SFnpJDivKnX
6zcwYOYaGK3euO3ehd1MiTT”2!Jny8
bff9VcTSJk7sRDLqKRVz1XGKbMqw3G
3.4 剩下的全部默认安装即可,此处不再赘述。
Reference
Ubuntu12.04 安装PyCharm (http://www.cnblogs.com/zhcncn/p/4027025.html)
ubuntu下Pycharm安装及配置 (http://blog.csdn.net/rebelqsp/article/details/21548969)
ubuntu12.04 安装配置jdk1.7 (http://blog.csdn.net/microfhu/article/details/7667393)