/**
* <pre>
* 1.If you try to change a public or protected <b>non-static</b> method into a
* <b>static</b> method or vice-versa,at that time also this exception will be thrown.
*
* 2.If you change a public or protected variable from <b>static</b>
* to non-static or vice-versa then this exception will be thrown .
*
*
* cp只是确定路径,被引用的java文件是否编译没有关系
*
* 1,在文件所在路径(com/aviary/android/feather/headless/utils)下直接javac *.java可以全部编译。如果引用,需要加上cp指向包的根所在的路径(javac -cp /Users/XCL/Documents/android/AAA-JavaTest/src/ B.java)。
* 没法在文件所在路径运行
* 2,在文件包的根路径(项目路径),执行javac ./com/aviary/android/feather/headless/utils/*.java可以全部编译,单独编译也可以
*
* 注意被引用的类package和说在位置要一致,java会验证
*
* package语句中包名必须与生成的class文件所在的目录保持一个关系,使得javac能够找到相应的class文件并且验证一个文件是否处于正确的包中
* javac会逐个尝试classpath的每个路径和文件的包名的组合,直到找到相应的class文件为止。但是如果通过classpath与包名的组合在多个不同的路径下都找到了同名类,则会返回错误信息。
*
* 寻找引用
* 1,不指定classpath,从javac的执行路径+引用的包名
* 2,指定了classpath,从classpath(引用包的路径)+引用的包名
*
*
* jar -cvf test.jar src一定要在包根路径在执行
*
*
*
*
*
project---|---src----------|---main---|---Test.java (默认包)
| |---package1---|---A.java (package package1;)
| | |---B.java (package package1;)
| |
| |---package2---|---C.java (package package2;)
| |---Makefile
|
|---classes------|---main---|---Test.class
|---package1---|---A.class
| |---B.class
|
|---package2---|---C.class
A.java,B.java,C.java独立,Test.java引用了A,B,C
------------------------------------------------------------------------
//Makefile
target:
javac ./package1/A.java -d ../classes
javac ./package1/B.java -d ../classes
javac ./package2/C.java -d ../classes
javac ./main/Test.java -d ../classes/main/ -classpath ../classes
run:
java -classpath ../classes/main;../classes Test
clean:
rm -rf ../classes/package1/*.class
rm -rf ../classes/package2/*.class
rm -rf ../classes/main/*.class
------------------------------------------------------------------------
运行:make(在project/src目录下)
http://www.cnblogs.com/haolujun/archive/2013/03/02/2939698.html
------------------------------------------------------------------------------------------------------------------
#!/bin/sh
# Define some constants
ONSSERVER=ONSServer
PROJECT_PATH=/root/iot-oid
JAR_PATH=$PROJECT_PATH/lib
BIN_PATH=$PROJECT_PATH/bin
SRC_PATH=$PROJECT_PATH/src/$ONSSERVER
# First remove the sources.list file if it exists and then create the sources file of the project
rm -f $SRC_PATH/sources
find $SRC_PATH/com -name *.java > $SRC_PATH/sources.list
# First remove the ONSServer directory if it exists and then create the bin directory of ONSServer
rm -rf $BIN_PATH/$ONSSERVER
mkdir $BIN_PATH/$ONSSERVER
# Compile the project
javac -d $BIN_PATH/$ONSSERVER -classpath $JAR_PATH/jdom.jar:$JAR_PATH/oro-2.0.8.jar @$SRC_PATH/sources.list
------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
#!/bin/sh
# Define some constants
ONSSERVER=ONSServer
PROJECT_PATH=/root/iot-oid
JAR_PATH=$PROJECT_PATH/lib
BIN_PATH=$PROJECT_PATH/bin
# Run the project as a background process nohup(后台执行该行命令,不加&,则执行方式为阻塞式)
java -classpath $BIN_PATH:$JAR_PATH/jdom.jar:$JAR_PATH/oro-2.0.8.jar com.ONSServer.DoUDPRequest &
------------------------------------------------------------------------------------------------------------------
-classpath参数毕竟太麻烦了,需要一个一个将用到的jar文件加上,可以直接将所有用到的.jar包复制到jdk/jer/lib/ext/下
javac -d $BIN_PATH/$ONSSERVER -classpath $JAR_PATH/jdom.jar:$JAR_PATH/oro-2.0.8.jar @$SRC_PATH/sources.list
其中-classpath参数毕竟太麻烦了,需要一个一个将用到的jar文件加上,可以直接将所有用到的.jar包复制到jdk/jer/lib/ext/下;另外-d $BIN_PATH/$ONSSERVER ,这样也太麻烦了,直接将源文件夹copy一份,不指定目标文件存放路径,默认生存到源文件夹下,然后执行find ./ -name *.java | xargs rm 直接删错所有源文件,然后将生成的.class文件copy到项目文件夹/WebRoot/WEB-INF/classes下,
再直接将WebRoot的文件复制到Tomcat下的项目文件夹下,直接启动Tomcat就可以运行了
http://blog.csdn.net/huagong_adu/article/details/6929817