How to Run a .Jar Java File
.jar files are used for archiving, archive unpacking. One of the essential features of jar file is loss-less data compression. Need to know how to run one? Here's how.
STEPS:
- Make sure you have Java installed on your system. Check this by typingjava -version into the command terminal. If you don't have the latest version of Java, update it before proceeding.
- Make the .jar file executable. A .jar file is made executable by collecting the class files of your Java application; compilers or JVM (Java Virtual Machine) understand these formats. .jar files execute from
javaw (Java web start). You need to set application's entry point within jar file. (An entry point is a class containing the main function of your application). You will set the entry point using the Manifest file. Here's how to do it:- The Jar tool automatically sets meta-inf/manifest.mf as path of the .jar file. When you open a default Manifest file, it should read "Manifest-Version: 1.0, Created-By: 1.6.0 (Sun Microsystems Inc)"
- Make a manifest addition .txt file. Enter Main Class: [Package Name].[Class Name], with the bracketed portions filled in with your specific information. (This is in the form of an attribute value pair.)
- Enter this terminal command to modify the Manifest file to include the application's entry point, changing the bracketed portions to your specific file names:jar cfm [jar file name] [manifest-addition] [input files]
- Review your Manifest file. After you set the entry point, it should read: "Manifest-Version: 1.0,Created-By: 1.6.0 (Sun Microsystems Inc), Main Class: [Package Name].[Class Name]"
- Alternatively, you can set the entry point using the .jar tool. This overrides the Main-class attribute in the Manifest's file. Enter the following terminal command:jar cfe [jar file name] [Package Name] [Class Name with
main function]
- Run your .jar file. Run the .jar file using the following command (the main method of your java application executes):java -jar [Jar file Name]
- Make it so that you can run your.jar file by double-clicking it (optional). To open the .jar file by double-clicking on it, change the directory to the location of javaw (java web start)
executable. Type the following command into terminal:C:\Program Files\Java\j2rex.y.z\bin\javaw.exe" -jar "%1" %*
Running a .jar File in Linux
- Open terminal. With Linux, double-clicking the .jar file opens it in a zip archiver showing the contents of the .jar file. Instead, right-click and select "Open Terminal."
- Execute the following command: $>java -jar [jar file name]
- Open your .jar file by double-clicking (optional). If you want to run the .jar file by double-clicking, then you might have to try changing the file type association (similar to the
instructions for Windows) for your flavour of Linux system.- Make sure the above command works.
- Type the following command into terminal: $>/usr/lib/jvm/jre-1.6.0-sun/bin/java -jar %f
- Set the path according to where Java is located on your system.
hadoop执行jar文件的命令
# hadoop jar HelloWorld.jar
原文地址:http://www.wikihow.com/Run-a-.Jar-Java-File
How to Run a .Jar Java File的更多相关文章
- How to Convert a Class File to a Java File?
What is a programming language? Before introducing compilation and decompilation, let's briefly intr ...
- 转:Java.file
类 java.io.File 的使用 使用 File 的软件包 java.awt 包含用于创建用户界面和绘制图形图像的所有类. java.io 通过数据流.序列化和文件系统提供系统输入和输出. jav ...
- jar -- java文档归档工具
参考文档 http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/jar.html http://blog.chinaunix.net ...
- Java File类总结和FileUtils类
Java File类总结和FileUtils类 文件存在和类型判断 创建出File类的对象并不代表该路径下有此文件或目录. 用public boolean exists()可以判断文件是否存在. Fi ...
- Java File 类的使用方法详解
Java File类的功能非常强大,利用Java基本上可以对文件进行所有的操作.本文将对Java File文件操作类进行详细地分析,并将File类中的常用方法进行简单介绍,有需要的Java开发者可以看 ...
- Java File 类的使用方法详解(转)
转自:http://www.codeceo.com/article/java-file-class.html Java File类的功能非常强大,利用Java基本上可以对文件进行所有的操作.本文将对J ...
- A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations: /usr/local/eclipse/
linux系统下jdk是已经安装好的情况之下软件出现 A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be av ...
- eclipse 启动问题Eclipse启动时报错:A Java RunTime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No java virtual machine was found after searching the following locat
从其他人直接复制的环境导致的问题. 正常双击出现当前异常,以管理员权限启动可以正常启动. ---------------------------Eclipse--------------------- ...
- Java:Linux上java -jar xxx.jar&java -cp 区别
java -cp java -cp 和 -classpath 一样,是指定类运行所依赖其他类的路径,通常是类库和jar包,需要全路径到jar包,多个jar包之间连接符:window上分号“;”.Lin ...
随机推荐
- Doragon Kuesuto 1.6
/* * <<D Q>> * * Author xkfx<wyzxk_fx@163.com> * * 游戏规则:利用适当的决策,在13回合内击杀恶龙取得胜利. * ...
- Win7_64位使用Mysql Odbc
1.首先不能安装Mysql Odbc 64位,因为我们的Mysql是32位,使用Mysql Odbc 64位连接Mysql 32位,报错:驱动程序与应用程序之间的体系结构不匹配. 2.要安装Mysql ...
- maven核心概念4
一.Maven坐标 1.1.什么是坐标? 在平面几何中坐标(x,y)可以标识平面中唯一的一点. 1.2.Maven坐标主要组成 groupId:组织标识(包名) artifactId:项目名称 ver ...
- Memcache的安装
下载安装包: wget http://www.memcached.org/files/memcached-1.4.32.tar.gz wget https://cloud.github.com/dow ...
- Nginx反向代理负载均衡
环境准备: 总共四台机器,两台装有Nginx的机器做负载均衡,两台机器装有Apache作为WEB服务器. 机器信息 hostname IP 说明 lb01 192.168.1.19 nginx主负载均 ...
- Python学习笔记3—字符串
原始字符串 使用\转义或者r,这种方法在网站设置网站目录结构的时候非常管用. >>> dos="c:\news" >>> print dos c ...
- hdu 5476 Explore Track of Point(2015上海网络赛)
题目链接:hdu 5476 今天和队友们搞出3道水题后就一直卡在这儿了,唉,真惨啊……看着被一名一名地挤出晋级名次,确实很不好受,这道恶心的几何题被我们3个搞了3.4个小时,我想到一半时发现样例输出是 ...
- ID和Name的区别
HTML元素的ID和Name属性的区别一直认为ID和NAME是一样的,两个又可以一起出现,甚是疑惑.今天BAIDU了一下,才发现里面大有文章.发出来研究研究:最classical的答案:ID就像是一个 ...
- ssh批量登录并执行命令(python实现)
局域网内有一百多台电脑,全部都是linux操作系统,所有电脑配置相同,系统完全相同(包括用户名和密码),ip地址是自动分配的.现在有个任务是在这些电脑上执行某些命令,者说进行某些操作,比如安装某些软件 ...
- JQuery基础汇总
1. 对象获取与赋值::$("#obj").val("Hello World!"); 2. 对象的显示与隐藏:$("#obj").show( ...