IDEA打jar包
IDEA版本:IntelliJ IDEA 2017.3.4 (Ultimate Edition)
写的代码如下:
打开File->Project Structure
选择Artifacts->点击"+"->选择JAR->选择From modules with dependencies
会跳出下页面
Module默认就是;
Main Class点击右侧选择:
跳出以下页面:
选择Project->选择main方法的类Hello
然后选择方式为:extract to the target JAR:
OK->跳出一下页面
Name:名字,可以改
Output directory:生成jar包的位置
Apply->OK
然后在选项栏里面选择Build->Build Artifacts
会跳出一下小窗口:
若报如下错(问题是后续补充,此时主题界面已换):
Cannot start compilation: the output path is not specified for module “creatPngNJ0001”.
Specify the output path in Configure Project
没有指定的输出路径问题
操作如下:
1.Project compiler output路径(即项目路径,没有可手动添加)后面加上out
2.选Inherit project compile output path
jar包打好之后会有如下提示:
指定的Output directory位置生成指定Name的jar
在路径栏输入cmd,回车 即可在当前位置打开命令窗口
输入 java -jar com.htht.jar
回车: