ç¹°ãè¿ãå®è¡å¯è½ãªã³ã³ãã¤ã«ããã
ããã°ã©ã ã®ã½ã¼ã¹ã³ã¼ããã³ã³ãã¤ã«ããå ´åï¼
- ï¼ï¼ï¼ããã³ã³ãã¤ã«æåããããâãããã§ããã°ã©ã ãå®éã«åããã¦ã¿ãã
- ï¼ï¼ï¼ããã³ã³ãã¤ã«å¤±æããããâãã½ã¼ã¹ã³ã¼ããä¿®æ£ããå¾ã§ï¼ããä¸åº¦ã³ã³ãã¤ã«å®è¡ããã
ã¨ããæµããä¸è¬çã ããã
ãããï¼ããã³ãã³ãã©ã¤ã³ããã³ã³ãã¤ã«ãå®è¡ãå®è¡ããå ´åï¼ãã¡ãã¡ãã³ã³ãã¤ã«ããããã¨ãå®è¡ãããããå¥ã ã«æ¢ãã¦åããã®ã¯é¢åã ã
ï¼ï¼ï¼ã¨ï¼ï¼ï¼ã®æä½ãï¼ã¹ã ã¼ãºã«ã¤ãªãã£ãã便å©ã§ã¯ã
ä¸è¨ã§ã¯ããããWindowsããããæ¸ãã¦ã¿ãã
ä¾ã¨ãã¦ï¼ã³ã³ãã¤ã«å¯¾è±¡ã®ã³ã¼ãã¯Javaã¨ããã
ï¼ï¼ï¼å®è¡ããã
èµ·åå¼æ°ï¼OPTï¼ä»ãã§ï¼JARããå®è¡ãããï¼JARã®ä½ãæ¹ã¯å¾è¿°ï¼
ããèµ·åå¼æ°ãä¸ããããªãã£ãå ´åã¯ï¼ããã©ã«ãã®å¤ï¼DEFAULT_OPTï¼ã使ãã
ä¸è¨ã®å 容ã exec_jar.bat ã§ä¿åã
@echo off set DEFAULT_OPT=10 set JARPATH=..\jar\jarname.jar set OPT=%1 if "%1" == "" set OPT=%DEFAULT_OPT% cls java -jar %JARPATH% %OPT% @pause
æ¦èª¬ï¼
- JARã«å¼æ°ã渡ããããããªå ´åï¼%1ï¼%2 çã§batã®å®è¡æå¼æ°ãåå¾
- cls ã§ç»é¢ã®æååãæ¶å»
ï¼ï¼ï¼ã³ã³ãã¤ã«ç¨ã®Antã¹ã¯ãªãã
Javaã§ï¼ããã½ã¼ã¹ãã¡ã¤ã«ã大éã«åå¨ããå ´åã¯ï¼ãããã®ã½ã¼ã¹ãå¹¾ã¤ãã®ãã©ã«ãã«åãã¦è¨ç½®ãããã¨ã«ãªãã
ãã©ã«ãã«åæ£ãããã¨ã¯ã¤ã¾ãï¼ã¯ã©ã¹ãå¹¾ã¤ãã®ããã±ã¼ã¸ã«åããã¨ããäºã ã
ããã¦ï¼JDKã® javac ã³ãã³ãã«ã¯ããã£ã¬ã¯ããªä»¥ä¸ã®å ¨ã¦ã®ããã±ã¼ã¸ãå帰çã«ã³ã³ãã¤ã«ãããã¨ããæ©è½ã¯ãªãã
ã ããï¼å ¨ããã±ã¼ã¸ãã¾ã¨ãã¦ä¸åº¦ã«ã³ã³ãã¤ã«ãããå ´åã¯ï¼Apache Antãªã©ã®ãã«ããã¼ã«ãå©ç¨ããå¿ è¦ãããã
â»åèï¼
Antã¡ã¢
http://muimi.com/j/jakarta/ant/#WhatIs
Antå¾¹åºæ´»ç¨
http://www.stackasterisk.jp/tech/java/ant01_01.jsp
Antã®ã¤ã³ã¹ãã¼ã«ãï¼Pathï¼ANT_HOMEã®è¨å®ãçµãã£ã段éã§ï¼ä¸è¨ã®å
容ã build.xml ã§ä¿åã
<project name="helloant" default="compile"> <property name="build_dir" value=".."/> <property name="src_dir" value="${build_dir}/src"/> <property name="classes_dir" value="${build_dir}/classes"/> <property name="jar_dir" value="${build_dir}/../jar"/> <property name="jar_file" value="${jar_dir}/jarname.jar"/> <property name="mf_file" value="${src_dir}/conf/MANIFEST.MF"/> <property name="doc_dir" value="${build_dir}/../doc/javadoc"/> <property name="pack_name" value="jp.co.ãããã±ã¼ã¸åã.*"/> <target name="compile"> <javac fork="true" srcdir="${src_dir}" destdir="${classes_dir}"/> </target> <target name="jar" depends="compile"> <jar basedir="${classes_dir}" destfile="${jar_file}" manifest="${mf_file}"/> </target> <target name="javadoc"> <javadoc destdir="${doc_dir}" packagenames="${pack_name}" sourcepath="${src_dir}/java" > </javadoc> </target> </project>
ããã§ã®ãã£ã¬ã¯ããªæ§æï¼
build bin build.xml srcã(ã½ã¼ã¹ãã£ã¬ã¯ããª) java jp co ..ï¼ä»¥ä¸ããã±ã¼ã¸æ§æãç¶ãï¼ conf MANIFEST.MF classes (ã¯ã©ã¹æ ¼ç´ç¨ãã£ã¬ã¯ããª) jar jarname.jarãï¼å®æåï¼ doc javadoc
æ¦èª¬ï¼
- ãã£ã¬ã¯ããªã»ãã¡ã¤ã«åãå¤æ°ã¨ãã¦å®£è¨ããã®ã¡ï¼targetãã¨ã«ã¿ã¹ã¯ãåæã
- Antã§javacã¿ã¹ã¯ãå®è¡ããéã«ã¯ï¼fork=true ãä»ããªãã¨ã¨ã©ã¼ã«ãªãã
- [ECLIPSE][ANT]Unable to find a javac compilerã¨ã©ã¼ã®è§£æ±º http://blog.livedoor.jp/ku_ri_/archives/492723.html
- JARã«åºããéã«ã¯ï¼ãããã§ã¹ããã¡ã¤ã«ãå¿
è¦ãä¸èº«ã¯ï¼Main-Class: ã§JARå®è¡æã®èµ·åã¯ã©ã¹ãæ¸ãã
- jarãã¡ã¤ã«ãããã«ã¯ãªãã¯ã§å®è¡ãã http://homepage2.nifty.com/ann/Windows/jar/Executable-Jar-File.htm
- javadocã¿ã¹ã¯ã§ã¯ï¼ããã±ã¼ã¸åãæå®ããéã«æå¾ã * ã§çµããããããã®ããã±ã¼ã¸åã®ã«ã¼ããã£ã¬ã¯ããªã sourcepath ã«æå®ããã
ããã§ä½ã£ããã«ãè¨å®ã«åºã¥ãã¦ãã«ããè¡ãªãããã«ã¯ï¼ã³ãã³ãããã³ãããã
ant -buildfile build.xml compile jar
ã¨ãããbuildfileãªãã·ã§ã³ã§XMLãèªã¿è¾¼ã¿ï¼ãã®ãã¨ã«å®è¡ãããã¿ã¹ã¯åã並ã¹ãã
ï¼ï¼ï¼ã³ã³ãã¤ã«ããã
åé ã¾ã§ã®å 容ã¯ï¼ã©ãã«ã§ãæ¸ãã¦ããåºç¤ã§ãã£ã¦ï¼ãããä»åã®ãã¢ã«ãªãã
build.xmlã¨åããã©ã«ãã«ï¼ä¸è¨ã®å 容ã compile.bat ã§ä¿åã
@echo off :start cls rem ----- ã³ã³ãã¤ã«å®è¡ ----- call ant -buildfile build.xml compile jar rem call ãä»ããªãã§ç´æ¥å¼ã³åºãã¨ï¼antã®å®è¡çµäºæã«ãã®ããããçµäºãã¦ãã¾ã rem ----- ãã¼å ¥åã§åå² ----- echo. set userkey= set /p userkey=çµäºãã (Enter) / å度ã³ã³ãã¤ã« (o + Enter) / ææç©ãå®è¡ (p + Enter) ? rem oã¯optimize, pã¯playã®ç¥ã®ã¤ãããEnterããè¿ããã¼ãããã if not '%userkey%'=='' set userkey=%userkey:~0,1% if '%userkey%'=='o' goto start if '%userkey%'=='p' goto exec goto quit :exec rem ----- ã³ã³ãã¤ã«çµæãå®è¡ ----- call exec_jar.bat :quit rem ----- çµäº -----
æ¦èª¬ï¼
- ã³ã³ãã¤ã«å®è¡ã®é¨åã§ã¯ï¼ï¼ï¼ã®ãã«ããï¼ã¾ãæå¾ã®å®è¡ã®é¨åã§ã¯ï¼ï¼ï¼ã®ããããå¼ã³åºãã¦ããã
- set /p ã§ï¼ã¦ã¼ã¶å ¥åã®æååãåãä»ãã¦ï¼ç°å¢å¤æ°ï¼ããã§ã¯userkeyã¨ããå¤æ°ï¼ã«æ ¼ç´ã§ããã
- :~0,1 ã使ã£ã¦ï¼ç°å¢å¤æ°ã®0æåç®ãã1æååãåãåºãã¦ããã
ãããå®è¡ããã¨ï¼ã³ã³ãã¤ã«ãå®è¡ãããå¾ã§ï¼
- çµäºãããï¼ï¼ã¨ã³ã¿ã¼ãã¼ï¼
- ç¶ãã¦å度ã³ã³ãã¤ã«ãããï¼ï¼oãæ¼ãï¼
- ã³ã³ãã¤ã«çµæãå®è¡ãããï¼ï¼pãæ¼ãï¼
ã®åå²ã«ãªãã
ããã³ã³ãã¤ã«æã«ã³ã³ãã¤ã«ã¨ã©ã¼ç®æããããã表示ããããï¼ã½ã¼ã¹ã³ã¼ããä¿®æ£ãã¦ãã o ãæ¼ä¸ããã°ããã
ããã³ã³ãã¤ã«ã¨ã©ã¼ã表示ãããªãã£ããªãã°ï¼ãã p ãæ¼ä¸ããã°ããã
ããããï¼éçºä¸ã«ä½åº¦ãä½åº¦ãå®è¡ããã¯ãã®æä½ãªã®ã§ï¼ãããã¦é£çµãããäºã§å°ãå¿«é©ã«ãªãã¯ãã
ï¼ããã«ã¯ãªãã¯ã®åæ°ãæ¸ããï¼
è£è¶³
ä¸è¨ã®æ©è½ã¯EclipseãVisual Studioãããã°ä¸åã ãã©ãï¼ãéããã¦IDEç«ã¡ä¸ããããªããã¨ããæã«ã¯çµæ§å½¹ç«ã¤ã
ä¾ãã°ï¼ä¸ããããéçºç¨ãã·ã³ãVistaã§ï¼ãã·ã³ãã¯ã¼ä¸ã®åé¡ãããã¨ããªã©â¦ã*1
ã*1:IMEã§ï¼ä¸åèªã®å¤æã«æ°ç§ï¼Eclipseã®ç«ã¡ä¸ãã«æ°åï¼Excelã§ãã¼ãã«å®ç¾©æ¸ããªã¼ãã³ããã®ã«10åãããï¼ãã¹ãå®è¡æã«ã¯ã¿ã¤ã ã¢ã¦ãã¨ã©ã¼ãèµ·ãããã¨ãããããªç°å¢ãããã¯æªå¤¢ã ã£ãã