본문 바로가기

java

Java -classpath 옵션

테스트 프로그램을 구현하다가 웹이 아닌 그냥 자바 클래스를 실행해야 하는 경우가 생겼다.

그런데 -classpath옵션이 windowunix를 틀린것을 발견했다. 웹프로그래밍만 하다 보니 이제껏 이걸 모르고 있었다는게 한심하다.

다른점은 구분자(semi-colon과 그냥 colon)의 차이점이다.

예를 들면 다음과 같다.

window

java -cp .;..\lib\mail.jar;..\lib\activation.jar mail.MailSender

 

unix

java -cp .:../lib/mail.jar:../lib/activation.jar mail.MailSender

 

javahelp를 보니.. 다음과 같이 정확하게 구분자가 나와 있었다.

window

c:\>ver

Microsoft Windows XP [Version 5.1.2600]

c:\>java -h

Usage: java [-options] class [args...]

           (to execute a class)

   or  java [-options] -jar jarfile [args...]

           (to execute a jar file)

 

where options include:

    -client       to select the "client" VM

    -server       to select the "server" VM

    -hotspot      is a synonym for the "client" VM  [deprecated]

                  The default VM is client.

 

    -cp <class search path of directories and zip/jar files>

    -classpath <class search path of directories and zip/jar files>

                  A ; separated list of directories, JAR archives,

                  and ZIP archives to search for class files.

    -D<name>=<value>

                  set a system property

    -verbose[:class|gc|jni]

                  enable verbose output

    -version      print product version and exit

    -version:<value>

                  require the specified version to run

    -showversion  print product version and continue

    -jre-restrict-search | -jre-no-restrict-search

                  include/exclude user private JREs in the version search

    -? -help      print this help message

    -X            print help on non-standard options

    -ea[:<packagename>...|:<classname>]

    -enableassertions[:<packagename>...|:<classname>]

                  enable assertions

    -da[:<packagename>...|:<classname>]

    -disableassertions[:<packagename>...|:<classname>]

                  disable assertions

    -esa | -enablesystemassertions

                  enable system assertions

    -dsa | -disablesystemassertions

                  disable system assertions

    -agentlib:<libname>[=<options>]

                  load native agent library <libname>, e.g. -agentlib:hprof

                    see also, -agentlib:jdwp=help and -agentlib:hprof=help

    -agentpath:<pathname>[=<options>]

                  load native agent library by full pathname

    -javaagent:<jarpath>[=<options>]

                  load Java programming language agent, see java.lang.instrument

 

unix

test|server:/user/test> uname -a

HP-UX server B.11.23 U ia64 3407499753 무제한-사용자 라이선스

test|server:/user/test> java -h

Usage: java [-options] class [args...]

           (to execute a class)

   or  java [-options] -jar jarfile [args...]

           (to execute a jar file)

 

where options include:

    -d32          use a 32-bit data model if available

    -d64          use a 64-bit data model if available

    -server       run the HotSpot VM, tuned for long-lived,

                  server applications (default)

    -hotspot      synonymous to the -server option

    -client       run the HotSpot VM, tuned for short-lived,

                  GUI applications

                  If present, the option to select the VM must be first.

                  The default VM is -server.

 

    -cp <class search path of directories and zip/jar files>

    -classpath <class search path of directories and zip/jar files>

                  A : separated list of directories, JAR archives,

                  and ZIP archives to search for class files.

    -D<name>=<value>

                  set a system property

    -verbose[:class|gc|jni]

                  enable verbose output

    -version      print product version and exit

    -version:<value>

                  require the specified version to run

    -showversion  print product version and continue

    -jre-restrict-search | -jre-no-restrict-search

                  include/exclude user private JREs in the version search

    -? -help      print this help message

    -X            print help on non-standard options

    -ea[:<packagename>...|:<classname>]

    -enableassertions[:<packagename>...|:<classname>]

                  enable assertions

    -da[:<packagename>...|:<classname>]

    -disableassertions[:<packagename>...|:<classname>]

                  disable assertions

    -esa | -enablesystemassertions

                  enable system assertions

    -dsa | -disablesystemassertions

                  disable system assertions

    -agentlib:<libname>[=<options>]

                  load native agent library <libname>, e.g. -agentlib:hprof

                    see also, -agentlib:jdwp=help and -agentlib:hprof=help

    -agentpath:<pathname>[=<options>]

                  load native agent library by full pathname

    -javaagent:<jarpath>[=<options>]

                  load Java programming language agent, see java.lang.instrument

'java' 카테고리의 다른 글

Tag Library Function  (0) 2009.01.19
Custom Tags in JSP Pages  (0) 2008.12.31
ClassLoader를 이용한 서버 종류 알아내기  (1) 2008.03.19
Tomcat과 JEUS에서의 EL  (0) 2008.01.22
Jakarta String Tag Library  (4) 2007.12.13