Java的运行路径classpath

1. eclipse下,可以通过-verbose查看类加载的顺序。


2.linux下执行

注意其中的 -classpath参数和 :/opt/hama-0.7.1/:/opt/hama-0.7.1/shareMemory.jar   shareMemory.ShareMemory &

需要将被执行main函数类的jar包加入-classpath中。

#!/usr/bin/env bash

/home/liuqiang2/jdk/jdk1.7.0_79/bin/java -Xmx2048m -Dhama.log.dir=/opt/hama-0.7.1/bin/../logs -Dhama.log.file=shareMemory.log -Dhama.home.dir=/opt/hama-0.7.1/bin/.. -Dhama.id.str=liuqiang2 -Dhama.root.logger=INFO,DRFA -Dhama.policy.file=hama-policy.xml -classpath /opt/hama-0.7.1/bin/../conf:/home/liuqiang2/jdk/jdk1.7.0_79/lib/tools.jar:/opt/hama-0.7.1/bin/../hama-commons-0.7.1.jar:/opt/hama-0.7.1/bin/../hama-core-0.7.1.jar:/opt/hama-0.7.1/bin/../hama-examples-0.7.1.jar:/opt/hama-0.7.1/bin/../hama-graph-0.7.1.jar:/opt/hama-0.7.1/bin/../hama-mesos-0.7.1.jar:/opt/hama-0.7.1/bin/../hama-ml-0.7.1.jar:/opt/hama-0.7.1/bin/../hama-yarn-0.7.1.jar:/opt/hama-0.7.1/bin/../lib/activation-1.1.jar:/opt/hama-0.7.1/bin/../lib/ant-1.6.5.jar:/opt/hama-0.7.1/bin/../lib/ant-1.7.1.jar:/opt/hama-0.7.1/bin/../lib/ant-launcher-1.7.1.jar:/opt/hama-0.7.1/bin/../lib/aopalliance-1.0.jar:/opt/hama-0.7.1/bin/../lib/apacheds-i18n-2.0.0-M15.jar:/opt/hama-0.7.1/bin/../lib/apacheds-kerberos-codec-2.0.0-M15.jar:/opt/hama-0.7.1/bin/../lib/api-asn1-api-1.0.0-M20.jar:/opt/hama-0.7.1/bin/../lib/api-util-1.0.0-M20.jar:/opt/hama-0.7.1/bin/../lib/asm-3.1.jar:/opt/hama-0.7.1/bin/../lib/avro-1.5.3.jar:/opt/hama-0.7.1/bin/../lib/commons-beanutils-1.8.3.jar:/opt/hama-0.7.1/bin/../lib/commons-cli-1.2.jar:/opt/hama-0.7.1/bin/../lib/commons-codec-1.4.jar:/opt/hama-0.7.1/bin/../lib/commons-collections-3.2.1.jar:/opt/hama-0.7.1/bin/../lib/commons-compress-1.9.jar:/opt/hama-0.7.1/bin/../lib/commons-configuration-1.7.jar:/opt/hama-0.7.1/bin/../lib/commons-daemon-1.0.13.jar:/opt/hama-0.7.1/bin/../lib/commons-digester-1.8.1.jar:/opt/hama-0.7.1/bin/../lib/commons-httpclient-3.0.1.jar:/opt/hama-0.7.1/bin/../lib/commons-io-2.4.jar:/opt/hama-0.7.1/bin/../lib/commons-lang-2.6.jar:/opt/hama-0.7.1/bin/../lib/commons-logging-1.1.1.jar:/opt/hama-0.7.1/bin/../lib/commons-math3-3.0.jar:/opt/hama-0.7.1/bin/../lib/commons-net-3.1.jar:/opt/hama-0.7.1/bin/../lib/core-3.1.1.jar:/opt/hama-0.7.1/bin/../lib/curator-client-2.7.1.jar:/opt/hama-0.7.1/bin/../lib/curator-framework-2.7.1.jar:/opt/hama-0.7.1/bin/../lib/curator-recipes-2.7.1.jar:/opt/hama-0.7.1/bin/../lib/geronimo-annotation_1.0_spec-1.0.jar:/opt/hama-0.7.1/bin/../lib/geronimo-spec-jta-1.0.1B-rc4.jar:/opt/hama-0.7.1/bin/../lib/gson-2.2.4.jar:/opt/hama-0.7.1/bin/../lib/guava-13.0.1.jar:/opt/hama-0.7.1/bin/../lib/guice-3.0.jar:/opt/hama-0.7.1/bin/../lib/guice-servlet-3.0.jar:/opt/hama-0.7.1/bin/../lib/hadoop-annotations-2.7.0.jar:/opt/hama-0.7.1/bin/../lib/hadoop-auth-2.7.0.jar:/opt/hama-0.7.1/bin/../lib/hadoop-common-2.7.0.jar:/opt/hama-0.7.1/bin/../lib/hadoop-hdfs-2.7.0.jar:/opt/hama-0.7.1/bin/../lib/hadoop-hdfs-2.7.0-tests.jar:/opt/hama-0.7.1/bin/../lib/hadoop-mapreduce-client-core-2.7.0.jar:/opt/hama-0.7.1/bin/../lib/hadoop-yarn-api-2.7.0.jar:/opt/hama-0.7.1/bin/../lib/hadoop-yarn-client-2.7.0.jar:/opt/hama-0.7.1/bin/../lib/hadoop-yarn-common-2.7.0.jar:/opt/hama-0.7.1/bin/../lib/htrace-core-3.1.0-incubating.jar:/opt/hama-0.7.1/bin/../lib/httpclient-4.2.5.jar:/opt/hama-0.7.1/bin/../lib/httpcore-4.1.2.jar:/opt/hama-0.7.1/bin/../lib/jackson-core-asl-1.9.2.jar:/opt/hama-0.7.1/bin/../lib/jackson-jaxrs-1.8.3.jar:/opt/hama-0.7.1/bin/../lib/jackson-mapper-asl-1.9.2.jar:/opt/hama-0.7.1/bin/../lib/jackson-xc-1.8.3.jar:/opt/hama-0.7.1/bin/../lib/javax.inject-1.jar:/opt/hama-0.7.1/bin/../lib/java-xmlbuilder-0.4.jar:/opt/hama-0.7.1/bin/../lib/jaxb-api-2.2.2.jar:/opt/hama-0.7.1/bin/../lib/jaxb-impl-2.2.3-1.jar:/opt/hama-0.7.1/bin/../lib/jdk.tools-1.7.jar:/opt/hama-0.7.1/bin/../lib/jersey-client-1.9.jar:/opt/hama-0.7.1/bin/../lib/jersey-core-1.9.jar:/opt/hama-0.7.1/bin/../lib/jersey-guice-1.9.jar:/opt/hama-0.7.1/bin/../lib/jersey-json-1.9.jar:/opt/hama-0.7.1/bin/../lib/jersey-server-1.9.jar:/opt/hama-0.7.1/bin/../lib/jets3t-0.9.0.jar:/opt/hama-0.7.1/bin/../lib/jettison-1.1.jar:/opt/hama-0.7.1/bin/../lib/jetty-6.1.14.jar:/opt/hama-0.7.1/bin/../lib/jetty-annotations-6.1.14.jar:/opt/hama-0.7.1/bin/../lib/jetty-plus-6.1.14.jar:/opt/hama-0.7.1/bin/../lib/jetty-util-6.1.14.jar:/opt/hama-0.7.1/bin/../lib/jline-0.9.94.jar:/opt/hama-0.7.1/lib/commons-logging-1.1.1.jar:/opt/hama-0.7.1/lib/slf4j-log4j12-1.5.8.jar:/opt/hama-0.7.1/lib/slf4j-api-1.5.8.jar:/opt/hama-0.7.1/lib/log4j-1.2.16.jar:/opt/hama-0.7.1/lib/leveldbjni-all-1.8.jar:/opt/hama-0.7.1/lib/protobuf-java-2.5.0.jar:/opt/hama-0.7.1/:/opt/hama-0.7.1/shareMemory.jar   shareMemory.ShareMemory &


3. 关于java -jar 在linux下的类加载顺序与执行路径,待查。



你可能感兴趣的:(Java的运行路径classpath)