Linux 命令行搭建Java环境
来源:互联网 发布:java面向对象特征 编辑:程序博客网 时间:2024/05/02 01:19
当Linux不启用图形界面的时候,我们只能通过命令行来搭建Java环境了。
平台: CentOS 6.5
1. 下载
不知道后续Oracle公司会不会会不会更新网址,所以以当前时间(2016年7月19日)为例。如果我们有浏览器,只需要输入以下网址:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
就能打开Java jdk 的下载页面了。然后下载即可。
下载的时候需要点击“Accept License Agreement ”,所以用这个命令:
wget http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz
下载下来的文件只有5K左右,只是一个一个HTML文件罢了。所以需要输入以下命令:
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz
这样就能下载jdk-8u91-linux-x64.tar.gz 这个压缩包了。
2. 解压
建立一个目录,如我这里建的目录是/usr/java/jdk8
。
mkdir /usr/javamkdir /usr/java/jdk8
利用以下命令解压刚才下载的jdk-8u91-linux-x64.tar.gz
压缩包。进入这个压缩包所在的目录,然后输入以下命令:
tar zxvf jdk-8u91-linux-x64.tar.gz -C /usr/java/jdk8/
解压之后/usr/java/jdk8/
目录下有一个目录:jdk1.8.0_91
。这就是JDK的安装目录。
3. 设置环境变量
修改配置文件:
vim ~/.bashrc
在文件中加入:
export JAVA_HOME=/usr/java/jdk8/jdk1.8.0_91/export JRE_HOME=${JAVA_HOME}/jreexport CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/libexport PATH=${JAVA_HOME}/bin:$PATH
然后输入命令让配置文件生效:
source ~/.bashrc
4. 测试
可以输入java
和javac
这两个命令测试一下。
输入java
输出结果:
Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file)where options include: -d32 use a 32-bit data model if available -d64 use a 64-bit data model if available -server to select the "server" VM The default VM is server. -cp <class search path of directories and zip/jar files> -classpath <class search path of directories and zip/jar files> A : separated list of directories, JAR archives, and ZIP archives to search for class files. -D<name>=<value> set a system property -verbose:[class|gc|jni] enable verbose output -version print product version and exit -version:<value> Warning: this feature is deprecated and will be removed in a future release. require the specified version to run -showversion print product version and continue -jre-restrict-search | -no-jre-restrict-search Warning: this feature is deprecated and will be removed in a future release. include/exclude user private JREs in the version search -? -help print this help message -X print help on non-standard options -ea[:<packagename>...|:<classname>] -enableassertions[:<packagename>...|:<classname>] enable assertions with specified granularity -da[:<packagename>...|:<classname>] -disableassertions[:<packagename>...|:<classname>] disable assertions with specified granularity -esa | -enablesystemassertions enable system assertions -dsa | -disablesystemassertions disable system assertions -agentlib:<libname>[=<options>] load native agent library <libname>, e.g. -agentlib:hprof see also, -agentlib:jdwp=help and -agentlib:hprof=help -agentpath:<pathname>[=<options>] load native agent library by full pathname -javaagent:<jarpath>[=<options>] load Java programming language agent, see java.lang.instrument -splash:<imagepath> show splash screen with specified imageSee http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
输入javac
的输出结果:
Usage: javac <options> <source files>where possible options include: -g Generate all debugging info -g:none Generate no debugging info -g:{lines,vars,source} Generate only some debugging info -nowarn Generate no warnings -verbose Output messages about what the compiler is doing -deprecation Output source locations where deprecated APIs are used -classpath <path> Specify where to find user class files and annotation processors -cp <path> Specify where to find user class files and annotation processors -sourcepath <path> Specify where to find input source files -bootclasspath <path> Override location of bootstrap class files -extdirs <dirs> Override location of installed extensions -endorseddirs <dirs> Override location of endorsed standards path -proc:{none,only} Control whether annotation processing and/or compilation is done. -processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process -processorpath <path> Specify where to find annotation processors -parameters Generate metadata for reflection on method parameters -d <directory> Specify where to place generated class files -s <directory> Specify where to place generated source files -h <directory> Specify where to place generated native header files -implicit:{none,class} Specify whether or not to generate class files for implicitly referenced files -encoding <encoding> Specify character encoding used by source files -source <release> Provide source compatibility with specified release -target <release> Generate class files for specific VM version -profile <profile> Check that API used is available in the specified profile -version Version information -help Print a synopsis of standard options -Akey[=value] Options to pass to annotation processors -X Print a synopsis of nonstandard options -J<flag> Pass <flag> directly to the runtime system -Werror Terminate compilation if warnings occur @<filename> Read options and filenames from file</span>
那就说明Java环境已经搭建好了。
1 0
- Linux 命令行搭建Java环境
- linux JAVA环境搭建
- java搭建linux环境
- linux搭建java环境
- Linux java环境搭建
- linux-java环境搭建
- linux-搭建java环境
- linux 搭建java 环境
- Linux 搭建 Java 环境
- linux搭建Java环境
- Linux下JAVA环境搭建
- Linux上搭建java环境
- Linux搭建java开发环境
- linux搭建java web环境
- linux下java环境搭建
- Linux上搭建java环境
- linux下搭建java环境
- Linux-Java开发环境搭建
- scala 借贷模式(loan pattern)通用实现
- 模块化的JavaScript开发的优势在哪里
- 关于算法的一点思考。。。
- .NET CORE实践(1)--Ubuntu下的Hello World
- STM32 FSMC控制器
- Linux 命令行搭建Java环境
- 使用汇编语言编程常见错误与技巧
- Error running app: Instant Run requires 'Tools | Android | Enable ADB integration' to be enabled.
- oracle常用命令
- SpringMVC 使用校验框架
- 171. Excel Sheet Column Number
- CABasicAnimation 使用
- APK 破解
- SVM再次总结 - 5 - SMO