我用javac手动编译Java代码,我收到以下错误:
Packet.java:13: error: cannot find symbol
public final PacketType type;
^
symbol: class PacketType
location: class Packet
Packet.java:22: error: cannot find symbol
type = PacketType.UNDEF;
^
symbol: variable PacketType
location: class Packet
Packet.java:26: error: cannot find symbol
type = PacketType.values()[message[0]];
^
symbol: variable PacketType
location: class Packet
3 errors
Packet.java:
package gameManager.gameServer;
import java.util.logging.Logger;
public class Packet {
private static final Logger LOGGER = Logger.getLogger(Class.class.getSimpleName());
public static final int PACKET_SIZE = 1024; //Packet size in bytes
public final PacketType type;
public final byte[] data = new byte[PACKET_SIZE-1]; //Data size is PacketSize minus PacketType Header
public Packet(byte[] message) {
if(message.length != PACKET_SIZE) {
LOGGER.warning("Tried to create a packet with insufficent amount of data");
type = PacketType.UNDEF;
return;
}
type = PacketType.values()[message[0]];
for(int i = 0; i < data.length; i++) {
data[i] = message[i+1];
}
}
}
PacketType.java:
package gameManager.gameServer;
public enum PacketType {
UNDEF, JOIN_SERVER, MOVE, SHOOT, CHANGE_INVENTORY;
}
我正在使用编译
javac PacketType.java && javac Packet.java
我不知道为什么这不会编译,我已经编译了PacketType.java并且Eclipse没有从Packet看到PacketType的问题
答案 0 :(得分:0)
将目录更改为 src ,请尝试以下命令:
javac -cp src ./src/gameManager/gameServer/Packet.java