简体   繁体   English

从JAR文件的输入创建BAT和JAR文件

[英]Create BAT- and JAR-files from input of JAR-file

I'm not experienced at all regarding java or programming in general. 一般而言,我对Java或编程完全没有经验。

However I would like to find out if this scenario is possible; 但是,我想找出这种情况是否可行;

I run a JAR-file which asks for some input strings. 我运行一个JAR文件,要求输入一些字符串。 The JAR-file use these strings to compile another JAR-file and a batch-file. JAR文件使用这些字符串来编译另一个JAR文件和批处理文件。

So far I tried a set-up like this: A java-project with three classes. 到目前为止,我尝试了这样的设置:一个带有三个类的java项目。 One that asks for input, one that creates a batch-file, and the last class is the code for the new JAR-file. 一个要求输入,一个创建一个批处理文件,最后一个类是新JAR文件的代码。

To create a batch-file is no problem. 创建批处理文件没有问题。 But how can I in a class create a JAR-file? 但是,如何在一个类中创建一个JAR文件?

I'm using Eclipse. 我正在使用Eclipse。

Thanks for your time! 谢谢你的时间!

Robert. 罗伯特

Batch files can only be created on the disk, and then you can execute that file by the file location. 批处理文件只能在磁盘上创建,然后您可以按文件位置执行该文件。 But to run commands, you dont need to call batch file, you can easily call "cmd.exe" with the "/c" argument and execute commands directly. 但是,要运行命令,您无需调用批处理文件,可以轻松地使用“ / c”参数调用“ cmd.exe”并直接执行命令。 A very good example for the above: Run cmd commands through java 上面的一个很好的例子: 通过Java运行cmd命令

Let me know if you have more questions! 如果您还有其他问题,请告诉我!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM