Java 略记

通常

编译Java app  javac appname.java

执行Java app  java appname(Java虚拟机)

此外,Setting an Entry Point with the JAR Tool(how to run *.jar)

The 'e' flag (for 'entrypoint'), introduced in JDK 6, creates or overrides the manifest's Main-Class attribute. It can be used while creating or updating a jar file. Use it to specify the application entry point without editing or creating the manifest file.

For example, this command creates app.jar where the Main-Class attribute value in the manifest is set to MyApp:



jar cfe app.jar MyApp MyApp.class

You can directly invoke this application by running the following command:



java -jar app.jar

If the entrypoint class name is in a package it may use a '.' (dot) character as the delimiter. For example, if Main.classis in a package called foo the entry point can be specified in the following ways:



jar cfe Main.jar foo.Main foo/Main.class

使用makefile编译,生成dex格式的jar文件(在dalvik VM上运行)

ANDROID_SRC_DIR = /home/ymy/android/android-4.2

android_dir_dx = /home/ymy/android/platform-tools/dx

all:

javac hello.java -cp ../framework/core.jar

$(android_dir_dx) --dex --output=hello.jar hello.class

clean:

@rm *.jar *.class

运行(dx是指anroid SDK 中的dx工具,负责将java.class转换为dex格式,以便在dalvik上运行)

dalvik -cp hello.jar hello   #classes.dex is created and stored inside in this hello.jar

你可能感兴趣的:(java)