gpt4 book ai didi

java - 编译多个类并传递命令行参数

转载 作者:行者123 更新时间:2023-11-30 05:54:51 24 4
gpt4 key购买 nike

如何使用命令行编译两个类(不使用其他软件)并向其传递参数?

我自己创建了一个 sources.txt 文件,其中包含每个类所在的定义。我通过使用以下命令来完成此操作

dir /s /B *.java > sources.txt

然后我尝试执行 javac @sources.txt 虽然这没有帮助,因为我收到以下错误:

error: invalid flag: C:\Users\Adrian
Usage: javac <options> <source files>
use --help for a list of possible options

此外,我的路径在我的用户名后面确实包含一个空格。阿德里安$.所以在sources.txt中它看起来像这样:C:\Users\Adrian $\

我确实尝试在它们周围加上引号或百分号,但随后出现错误,指出未找到该文件。

<小时/>

完整主要代码:

package me.adrian;

import java.io.FileNotFoundException;

public class Main {

public static void main(String[] args) {
CSVoperator CSVfile = new CSVoperator();

try {
CSVfile.readCSV(args); //get args into there.
}
catch (FileNotFoundException e){
e.printStackTrace();
}
}

}

最佳答案

在on命令中指定多个名称可以直接编译

javac file1.java file2.java

或者使用*,当前目录中的所有.java文件将被编译

javac *.java

关于java - 编译多个类并传递命令行参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53345175/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com