1、场景:

  争对网上的很多文章中javac编译与java运行的文章,有很多不明确的地方,使得在合适时发现很多坑。这里给大家作下简介。

2、Javac的使用注意:

  javac -d ./ ./InstallCert.java

  其中-d表示要编译到哪里,加-d的目地是让后面加的java文件编译后,可以产生由package名称所确定的文件夹结构下的class文件。这样再运行java去执行时,就不会提示找不到类模块了。

3、Java的使用注意:

  java -classpath ./;c:mylib.jar;c:mylib2.jar packagename.className

  其中-classpath后面指定./表示前面 javac 编译时-d所指定的目录,之后加所依赖的jar文件,注意的是,windows上要用;分隔,而linux上要用:分隔。最后加空格加上包名.类名。

  如:

"C:Program Files (x86)Javajdk1.8.0_111injava.exe" -classpath D:ProjectJavaProjectAzureDemo	argetclasses;C:Usersyungoal.m2epositorycommicrosoftazureazure1.0.0-beta3azure-1.0.0-beta3.jar;C:Usersyungoal.m2epositorycommicrosoftazureazure-client-runtime1.0.0-beta3azure-client-runtime-1.0.0-beta3.jar;C:Usersyungoal.m2epositorycommicrosoftazureazure-client-authentication1.0.0-beta3azure-client-authentication-1.0.0-beta3.jar;C:Usersyungoal.m2epositorycommicrosoftazureadal4j1.1.2adal4j-1.1.2.jar;C:Usersyungoal.m2epositorycom
imbusdsoauth2-oidc-sdk4.5oauth2-oidc-sdk-4.5.jar;C:Usersyungoal.m2epositoryjavaxmailmail1.4.7mail-1.4.7.jar;C:Usersyungoal.m2epositoryjavaxactivationactivation1.1activation-1.1.jar;C:Usersyungoal.m2epository
etjcipjcip-annotations1.0jcip-annotations-1.0.jar;C:Usersyungoal.m2epository
etminidevjson-smart1.1.1json-smart-1.1.1.jar;C:Usersyungoal.m2epositorycom
imbusdslang-tag1.4lang-tag-1.4.jar;C:Usersyungoal.m2epositorycom
imbusds
imbus-jose-jwt3.1.2
imbus-jose-jwt-3.1.2.jar;C:Usersyungoal.m2epositoryorgouncycastlecprov-jdk15on1.51cprov-jdk15on-1.51.jar;C:Usersyungoal.m2epositorycomgooglecodegsongson2.2.4gson-2.2.4.jar;C:Usersyungoal.m2epositoryorgslf4jslf4j-api1.7.5slf4j-api-1.7.5.jar;C:Usersyungoal.m2epositorycommicrosoftazureazure-mgmt-resources1.0.0-beta3azure-mgmt-resources-1.0.0-beta3.jar;C:Usersyungoal.m2epositorycommicrosoftazureazure-mgmt-storage1.0.0-beta3azure-mgmt-storage-1.0.0-beta3.jar;C:Usersyungoal.m2epositorycommicrosoftazureazure-mgmt-network1.0.0-beta3azure-mgmt-network-1.0.0-beta3.jar;C:Usersyungoal.m2epositorycommicrosoftazureazure-mgmt-compute1.0.0-beta3azure-mgmt-compute-1.0.0-beta3.jar;C:Usersyungoal.m2epositorycommicrosoftazureazure-mgmt-graph-rbac1.0.0-beta3azure-mgmt-graph-rbac-1.0.0-beta3.jar;C:Usersyungoal.m2epositorycommicrosoftazureazure-mgmt-keyvault1.0.0-beta3azure-mgmt-keyvault-1.0.0-beta3.jar;C:Usersyungoal.m2epositorycommicrosoftazureazure-mgmt-batch1.0.0-beta3azure-mgmt-batch-1.0.0-beta3.jar;C:Usersyungoal.m2epositorycommicrosoftazureapi-annotations.0.1api-annotations-0.0.1.jar;C:Usersyungoal.m2epositorycommicrosoftestclient-runtime1.0.0-beta3client-runtime-1.0.0-beta3.jar;C:Usersyungoal.m2epositorycomgoogleguavaguava18.0guava-18.0.jar;C:Usersyungoal.m2epositorycomsquareupetrofit2etrofit2.0.2etrofit-2.0.2.jar;C:Usersyungoal.m2epositorycomsquareupokhttp3okhttp3.3.1okhttp-3.3.1.jar;C:Usersyungoal.m2epositorycomsquareupokiookio1.8.0okio-1.8.0.jar;C:Usersyungoal.m2epositorycomsquareupokhttp3logging-interceptor3.3.1logging-interceptor-3.3.1.jar;C:Usersyungoal.m2epositorycomsquareupokhttp3okhttp-urlconnection3.3.1okhttp-urlconnection-3.3.1.jar;C:Usersyungoal.m2epositorycomsquareupetrofit2converter-jackson2.0.2converter-jackson-2.0.2.jar;C:Usersyungoal.m2epositorycomfasterxmljacksoncorejackson-databind2.7.2jackson-databind-2.7.2.jar;C:Usersyungoal.m2epositorycomfasterxmljacksondatatypejackson-datatype-joda2.7.2jackson-datatype-joda-2.7.2.jar;C:Usersyungoal.m2epositorycomfasterxmljacksoncorejackson-annotations2.7.0jackson-annotations-2.7.0.jar;C:Usersyungoal.m2epositorycomfasterxmljacksoncorejackson-core2.7.2jackson-core-2.7.2.jar;C:Usersyungoal.m2epositoryjoda-timejoda-time2.4joda-time-2.4.jar;C:Usersyungoal.m2epositoryorgapachecommonscommons-lang33.4commons-lang3-3.4.jar;C:Usersyungoal.m2epositoryioeactivexxjava1.1.8xjava-1.1.8.jar;C:Usersyungoal.m2epositorycomsquareupetrofit2adapter-rxjava2.0.2adapter-rxjava-2.0.2.jar;C:Usersyungoal.m2epositorycommicrosoftazureazure-keyvault1.0.0-beta3azure-keyvault-1.0.0-beta3.jar;C:Usersyungoal.m2epositorycommicrosoftazureazure-keyvault-webkey1.0.0-beta3azure-keyvault-webkey-1.0.0-beta3.jar;C:Usersyungoal.m2epositorycommons-codeccommons-codec1.10commons-codec-1.10.jar com.test.azuredemo.Test