模拟eclipse应用批处理玩转java轻松实现项目编译运行打包发布.docx
- 文档编号:2420303
- 上传时间:2022-10-29
- 格式:DOCX
- 页数:14
- 大小:116.75KB
模拟eclipse应用批处理玩转java轻松实现项目编译运行打包发布.docx
《模拟eclipse应用批处理玩转java轻松实现项目编译运行打包发布.docx》由会员分享,可在线阅读,更多相关《模拟eclipse应用批处理玩转java轻松实现项目编译运行打包发布.docx(14页珍藏版)》请在冰豆网上搜索。
模拟eclipse应用批处理玩转java轻松实现项目编译运行打包发布
模拟eclipse,应用批处理玩转java,轻松实现项目,编译,运行,打包,发布
一、构建工作区间
1、在一个合适的文件夹新建一个名为workspace作为我们的工作空间,当然要有合适的空间,可以不建。
2、workspace新建一个文件夹,名为template,用于存放我们的模版文件,这个模版文件夹里面我们项目的模版,会被导入我们新建项目之中
3、在template下,建立template为后缀的模版文件,其中如果名称为default.template,则为默认模版,其他为可选模版
如下图:
模版文件编写举例:
package请您把我替换成合适的包名;
publicclass#CLASSNAME#{
/**
*@paramargs
*/
publicstaticvoidmain(String[]args){
//TODO自动生成的方法存根
}
}
用此模版生成的类文件会有main方法,基本上就是把模版简单拷贝而已,假如模版文件包含"#CLASSNAME#“(区分大小写)
此时到我们新建项目时,会自动把"#CLASSNAME#“替换成我们的类名,没有便不做任何操作
4、在workspace文件夹下,新建一个名为“新建项目.bat”的文本文件(注意要把隐藏已知文件扩展名哪项去掉),右键“新建项目.bat”,然后点“编辑”
打开该文档
此时点击“格式”查看“自动换行”那一选项是否打√,如果打了,请去掉,也就是不要自动换行
然后,把下面的黑色代码复制到里面(不要复制错了哦,差一个字符都会出错)
@echooff
:
start
echo请输入项目名称:
set/pa=
ifnotexist%a%gotonexist
set/pc=文件已经存在了,是否要覆盖原有文件(Y/N):
if"%c%"equ"Y"gotonexist
if"%c%"equ"y"gotonexist
if"%c%"equ"N"gotoeof
if"%c%"equ"n"gotoeof
gotostart
:
nexist
md%a%%a%\src%a%\lib%a%\bin
ifexisttemplategotop
md%a%\template
gotop0
:
p
echod|xcopy%cd%\template%a%\template/s/e
:
p0
rem新建文件
echo@echooff>new_file_operation.tmp
echo:
start>>new_file_operation.tmp
echoset^/pa=^请输入公共类名称:
>>new_file_operation.tmp
echoifnotexistsrc\%%a%%.javagotonexist>>new_file_operation.tmp
echoset^/pc=^文件已经存在了,是否要覆盖原有文件(Y^/N^):
>>new_file_operation.tmp
echoif"%%c%%"equ"Y"gotonexist>>new_file_operation.tmp
echoif"%%c%%"equ"y"gotonexist>>new_file_operation.tmp
echogotostart>>new_file_operation.tmp
echo:
nexist>>new_file_operation.tmp
echoset^/pd=^是否选用默认模版(Y^/N^):
>>new_file_operation.tmp
echoif"%%d%%"equ"n"gotonotdefault>>new_file_operation.tmp
echoif"%%d%%"equ"N"gotonotdefault>>new_file_operation.tmp
echoifnotexisttemplate\default.templategoton0>>new_file_operation.tmp
echotypetemplate\default.template^>src\%%a%%.java>>new_file_operation.tmp
echogotoexchange>>new_file_operation.tmp
echo:
notdefault>>new_file_operation.tmp
echoset^/pb=^请输入模版名称:
>>new_file_operation.tmp
echoifnotexisttemplate\%%b%%.templategoton0>>new_file_operation.tmp
echotypetemplate\%%b%%.template^>src\%%a%%.java>>new_file_operation.tmp
echorem替换部分>>new_file_operation.tmp
echo:
exchange>>new_file_operation.tmp
echosetlocalenabledelayedexpansion>>new_file_operation.tmp
echoseth=^1>>new_file_operation.tmp
echofor^/f"delims=^"%%%%iin^('type"src\%%a%%.java"'^)do^(>>new_file_operation.tmp
echosetstr=%%%%i>>new_file_operation.tmp
echoif!
h!
EQU1^(>>new_file_operation.tmp
echoset"str=!
str:
#CLASSNAME#=%%a%%!
">>new_file_operation.tmp
echoif"%%%%i"NEQ"!
str!
"seth=^0>>new_file_operation.tmp
echo^)>>new_file_operation.tmp
echoecho!
str!
^>^>tmp_file_for_copy.txt>>new_file_operation.tmp
echo^)>>new_file_operation.tmp
echodelsrc\%%a%%.java>>new_file_operation.tmp
echotypetmp_file_for_copy.txt^>src\%%a%%.java>>new_file_operation.tmp
echodeltmp_file_for_copy.txt>>new_file_operation.tmp
echogotoeof>>new_file_operation.tmp
echo:
n0>>new_file_operation.tmp
echoecho模版不存在,没有使用模版>>new_file_operation.tmp
echoechopackage请您把我改成包名;^>src\%%a%%.java>>new_file_operation.tmp
echoecho.^>^>src\%%a%%.java>>new_file_operation.tmp
echoechopublicclass%%a%%{^>^>src\%%a%%.java>>new_file_operation.tmp
echoecho.^>^>src\%%a%%.java>>new_file_operation.tmp
echoecho.^>^>src\%%a%%.java>>new_file_operation.tmp
echoecho.^>^>src\%%a%%.java>>new_file_operation.tmp
echoecho.^>^>src\%%a%%.java>>new_file_operation.tmp
echoecho.^>^>src\%%a%%.java>>new_file_operation.tmp
echoecho.^>^>src\%%a%%.java>>new_file_operation.tmp
echoecho.^>^>src\%%a%%.java>>new_file_operation.tmp
echoecho.^>^>src\%%a%%.java>>new_file_operation.tmp
echoecho.^>^>src\%%a%%.java>>new_file_operation.tmp
echoecho}^>^>src\%%a%%.java>>new_file_operation.tmp
echo:
eof>>new_file_operation.tmp
echostartC:
\Windows\System32\notepad.exesrc\%%a%%.java>>new_file_operation.tmp
rem打开部分
echoecho@echooff^>打开.bat>>new_file_operation.tmp
echoecho:
start^>^>打开.bat>>new_file_operation.tmp
echoechoset^^/pd=^^是否打开上次文件Y^^/N^^):
^>^>打开.bat>>new_file_operation.tmp
echoechoif"%%%%d%%%%"equ"n"gotondefault^>^>打开.bat>>new_file_operation.tmp
echoechoif"%%%%d%%%%"equ"N"gotondefault^>^>打开.bat>>new_file_operation.tmp
echoechostartC:
\Windows\System32\notepad.exesrc\%%a%%.java^>^>打开.bat>>new_file_operation.tmp
echoechoexit^>^>打开.bat>>new_file_operation.tmp
echoecho:
ndefault^>^>打开.bat>>new_file_operation.tmp
echoechoset^^/pxx=^^请输入要打开的公共类名称:
^>^>打开.bat>>new_file_operation.tmp
echoechostartC:
\Windows\System32\notepad.exesrc\%%%%xx%%%%.java^>^>打开.bat>>new_file_operation.tmp
typenew_file_operation.tmp>>%a%\新建.bat
delnew_file_operation.tmp
rem编译部分
echo@echooff^&setlocalenabledelayedexpansion>translate_file_operation.tmp
echosetstr1=>>translate_file_operation.tmp
echofor^/r.\src%%%%iin^(*.java^)dosetst
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 模拟 eclipse 应用 批处理 java 轻松 实现 项目 编译 运行 打包 发布
