How to import libraries from JAR-files into a Java program using TextMate -
i need write simple program in java , love same way program in python , ruby using textmate. can write , run simple hello world program, cannot find way how load external libraries. need compile *.jar files working directory (or need intall them first?). first java-experience, appreciate detailed answer.
i prefer code in textmate not ide, wonder if possible java.
to able use classes stored inside jar file in program, jar file must part of classpath.
read http://en.wikipedia.org/wiki/classpath explanations on how set classpath. note true when compiling program.
suppose you're @ root of source directory , want compile java file , put class in classes directory:
javac -d ../classes -classpath c:\foo\bar\library1.jar;c:\foo\bar\library2.jar com/foo/bar/helloworld.java
now run class:
java -classpath ..\classes;c:\foo\bar\library1.jar;c:\foo\bar\library2.jar com.foo.bar.helloworld
when program becomes bigger 2 or 3 classes, you'll want use build tool ant, gradle or maven build application.
Comments
Post a Comment