public class Test{
public static void main(String [] args){
System.out.println(“参数为:”+args[0]);
}
}
1、执行类
无包
javac Test.java
java Test hello
有包
java com.Test.java
java com.Test hello
2、执行Jar
无包
jar cfmv test.jar mymanifest Test.class
java -jar test.jar hello
mymainfest内容为:
1
nifest-Version: 1.0
2 Created-By: 1.8.0_60 (Oracle Corporation)
3 Main-Class: Test
2 Created-By: 1.8.0_60 (Oracle Corporation)
3 Main-Class: Test
4
有包
jar cfmv test.jar mymanifest com/Test.class
java -jar test.jar hello
mymainfest内容为:
1
nifest-Version: 1.0
2 Created-By: 1.8.0_60 (Oracle Corporation)
3 Main-Class: com.Test
2 Created-By: 1.8.0_60 (Oracle Corporation)
3 Main-Class: com.Test
4
3、引入自定义jar
无包
javac -cp "bbtree-commons-core-1.2.46.jar" Test.java
java -classpath "/Users/chenzhilei/.m2/repository/commons-codec/commons-codec/1.8/commons-codec-1.8.jar:bbtree-commons-core-1.2.46.jar:/Users/chenzhilei/.m2/repository/org/bouncycastle/bcprov-jdk15/1.45/bcprov-jdk15-1.45.jar:" Test b1f12a5c4a4c80a59c4bee51e31e5c56 hello
有包
javac -cp "com/bbtree-commons-core-1.2.46.jar" com/Test.java
java -classpath "/Users/chenzhilei/.m2/repository/commons-codec/commons-codec/1.8/commons-codec-1.8.jar:com/bbtree-commons-core-1.2.46.jar:/Users/chenzhilei/.m2/repository/org/bouncycastle/bcprov-jdk15/1.45/bcprov-jdk15-1.45.jar:" com.Test b1f12a5c4a4c80a59c4bee51e31e5c56 hello
代码
1
//package com;
2
import
com.bbtree.commons.core.utils.AESUtils;
3
4
/**
5
*
Created by chenzhilei on 16/5/15.
6
*/
7
public
class
Test {
8
public
static
void
main(String[] args)
throws
Exception {
9
String encrypt = AESUtils.encrypt(args[
0
], args[
1
]);
10
System.out.println(
"encrypt:"
+ encrypt);
11
String decrypt = AESUtils.decrypt(args[
0
], encrypt);
12
System.out.println(
"decrypt:"
+ decrypt);
13
}
14
}