帮助请求:让批处理 Java 编译器完成工作

发布于 2024-11-08 22:15:56 字数 768 浏览 2 评论 0原文

好的,所以我一直在为 Java 文件制作这个一体化批处理文件编译器,来编译类文件、清单文件和 Jar 文件。一切正常,但有一件事......我似乎无法弄清楚如何在某些情况下调用另一条路径......我将在批处理代码下面解释一个案例示例:

@ echo off
COLOR 0a
Title Leaum's All-In-One Java Compiler

echo Compiling The Class Files...
"Whattt to do here?!" C:\JavaApps
javac -classpath . *.java
Pause
cls

echo Type the CLASS File Name Exactly...
set Man=
set /p Man=Type CLASS File Name: %=%
pause
echo Compiling The Manfiest File...
echo Main-Class: %Man%>>manifest.txt
pause
cls

我将其发布在pastebin中,因为代码很奇怪。 无论如何,以第 6 行为例,假设我希望它在需要时调用该文件夹来搜索某些 .Java 文件。当我编译一个包含“TextIO.putln”代码的Java文件时,我需要它调用TextIO.java/Class文件才能正确编译,我只想存储所有独立/ applet 文件放在单独的目录中...并将其包含在类编译器中,但仍然在当前项目 .Java 所在的目录中创建类文件...如果这有意义吗?我似乎找不到一种方法让它调用 TextIO:3。

任何帮助都会很棒。谢谢你!

Ok, So I have been making this All-in-One Batch File Compiler for Java Files, to compile the Class Files, Manifest files, and the Jar Files. Everything works but one thing... I can't seem to figure out how to call another path in certain cases.. I will explain a case example below the Batch Code:

@ echo off
COLOR 0a
Title Leaum's All-In-One Java Compiler

echo Compiling The Class Files...
"Whattt to do here?!" C:\JavaApps
javac -classpath . *.java
Pause
cls

echo Type the CLASS File Name Exactly...
set Man=
set /p Man=Type CLASS File Name: %=%
pause
echo Compiling The Manfiest File...
echo Main-Class: %Man%>>manifest.txt
pause
cls

I posted it in pastebin because the code thing was being weird.
Anyway, Line 6 for example, let's say I want it to call that Folder to Search for certain .Java Files when it needs to. When ever I am compiling a Java file that contains for example "TextIO.putln" Code, I would need it to call the TextIO.java/Class file in order for it to compile correctly, and I just want to store all the standalone/applet files in a separate directory... And have it include that in the Class Compiler, But still create the Class Files in what ever directory the Current project .Java is in.. If any of this makes sense? I can't seem to find a way to make it call the TextIO though :3.

Any help would be great. Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

帅哥哥的热头脑 2024-11-15 22:15:56

不要重新发明这个轮子,尤其是在特定于平台的语言中!

学习 Maven 3 或至少 Ant 甚至 GradleSCons 甚至比 Windows 特定的批处理文件更可取,从您所采用的方法中没有任何值得学习的东西。

Don't re-invent this wheel, especially in a platform specific language!

Learn Maven 3 or at least Ant or even Gradle. SCons would even be preferable to Windows specific batch files, there is nothing of value to learn from the approach you are taking.

小女人ら 2024-11-15 22:15:56

如果我正确理解你的问题,你只需要将包含实用程序类的目录添加到编译器的类路径中,例如:

javac -classpath .;C:\JavaApps *.java

但我确实同意 Jarrod 和其他人的观点,从长远来看,最好学会使用构建工具。

If I'm understanding your question right, you simply need to add the directory containing your utility classes to the classpath for the compiler, e.g.:

javac -classpath .;C:\JavaApps *.java

But I do agree with Jarrod and others that, in the long run, it is better to learn to use a build tool.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文