堆栈溢出
在使用Gradle构建java应用程序时遇到了一个问题。在构建jar文件之后,尝试使用
java -jar ZoneNewsDiscordBot-1.0-SNAPSHOT.jar
在航站楼找到了这个
Error: Could not find or load main class Main
我的项目文件的
- ...
- .idea
- build
- classes
- java
- main
- Main.class
- NewsGenerator.class
我创建了一个没有包名的项目和Hello.java文件。
public class Hello {
public String sayHello(){
return "Say Hello";
}
}
我将这个项目导出到hello.jar中。
现在,我已经创建了另一个项目和Main.java来调用sayHello()方法。我在类路径中添加了hello.jar,但是下面的代码显示错误“Hello不能解析为类型”
public class Main {
public static void main(String[] args){
Hello
在用尽互联网寻找在运行中的JAR文件中写入数据流的适当方法之后,我不知道如何获取数据流(例如字符串)并输出到*.jar旁边的一个*.jar文件中。以下是我的写作尝试:
InputStream stream = new ByteArrayInputStream("some string".getBytes("UTF-8"));
OutputStream resStreamOut = new FileOutputStream(new File("/dir-next-to-jar/some.txt"));
int readBytes;
byte[] b
我有以下Ant构建文件:
<?xml version="1.0"?>
<!-- the value of the default attr must be one of the targets. -->
<project name="Money" default="build-source" basedir=".">
<description>The Money project build file.</description>
&