简体   繁体   中英

Build an eclipse Java project without Eclipse

I would like to build my Java project from command line via a single command or external script, not using Eclipse, but just with the JDK. My project has 6 .jar libraries and 6 .java source files. If I need to compile each first, I can do that. I don't want to use ANT or MAVEN. Just plain .sh for now.

There's probably an answer somewhere how to build with libraries and multiple classes, but most search result show Eclipse, Ant, and Maven. There is how to compile each class, to create a .class file. In Eclipse, I even already have that in /bin, so I could just link those together (or could I just run the .class file?) somehow.

So, what command can I use to build a project with 6 .jar files and 6 .java files? I see this ( Including jars in classpath on commandline (javac or apt) ), but I also want to have separate build directory and am confused whether the class-path should be the build or source directory or both.

Use the javac compiler from the Java SE development kit to compile Java source files. You can use the existing Java ME Platform SDK project directory structure. Use the -bootclasspath option to tell the compiler to use the MIDP APIs, and use the -d option to tell the compiler where to put the compiled class files.

The following example demonstrates how you might compile a MIDP 2.0 application, taking source files from the src directory and placing the class files in the tmpclasses directory. Newlines have been added for clarity.

javac -target 1.3 -source 1.3 
   -bootclasspath ../../lib/cldc_10.jar;../../lib/midp2.0.jar
   -d tmpclasses
   src/*.java

For the complete guide on how to execute/build code from the command line, consider looking on the official java website: http://docs.oracle.com/javame/dev-tools/jme-sdk-3.0-mac/UserGuide-html/z400007747176.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM