我是java新手,如何在Intelij中编译包
这是我的目录
它在www.example.com上运行得很好Main.java
为了编译,我首先运行
javac people/People.java
然后我编译javac Main.java,它返回Main.java:8:错误:软件包com.amigoscode.people不存在
Main.java
package com.amigoscode;
// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
import java.util.Scanner;
import com.amigoscode.people.People;
public class Main {
public static void main(String[] args) {
People p = new People();
System.out.println(p.fullName());
}
}
People.java
package com.amigoscode.people;
public class People {
public String fname = "John";
public String lname = "Doe";
public int age = 24;
public String fullName() {
String fullName = fname + " " + lname;
return fullName;
}
}
非常感谢。
1条答案
按热度按时间9fkzdhlc1#
首先,使用terminal导航到
src
目录。然后执行下面的命令来编译People.java
。现在,要编译
Main.java
,请执行以下命令。这个应该没问题