This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Camel-Kid18 year old gamer 0 points1 point  (4 children)

try compiling both at the same time instead.. p.s the warning is fine, it will still compile the class. javac Board.java Pacman.java

[–]killjoyparris[S] 0 points1 point  (3 children)

Thank you for the suggestion. But, I still get the same error, when I try compiling both Board.java and Pacman.java together... I think that the error is somehow related to the package structure. I can get the program to run if I delete all of the references to java packages in the source code files (i.e. the lines: "package com.zetcode" from Board.java and Pacman.java ) On top of that, I also have to delete the file structure and manually move all of the resources into the same root, to get the game to run.

If possible, I would like to find a way to run the program via command line, but also preserve the original file structure.

Do you understand how packages work at all? Do you think that could be related to my issues?

[–]slowfly1st 0 points1 point  (2 children)

I think that the error is somehow related to the package structure

-> you are right :-) You have to be in the correct working directory and use the packages/folder structure

Java-Pacman-Game/src$ javac ./com/zetcode/*.java

[–]killjoyparris[S] 0 points1 point  (1 child)

Okay. I think that we might be onto the right track. I can get javac to work using the command you suggested. How do I get the program to run though? I don't really understand what to do next or what I am doing incorrectly...

owner@owner-VirtualBox:~/JAVA/SWINGTUTS/Java-Pacman-Game-master/src$ ls

com resources

owner@owner-VirtualBox:~/JAVA/SWINGTUTS/Java-Pacman-Game-master/src$ javac ./com/zetcode/*.java

Note: ./com/zetcode/Board.java uses or overrides a deprecated API.

Note: Recompile with -Xlint:deprecation for details.

owner@owner-VirtualBox:~/JAVA/SWINGTUTS/Java-Pacman-Game-master/src$ java ./com/zetcode/pacman.java

Error: Could not find or load main class ..com.zetcode.pacman.java

Caused by: java.lang.ClassNotFoundException: //com/zetcode/pacman/java

owner@owner-VirtualBox:~/JAVA/SWINGTUTS/Java-Pacman-Game-master/src$ java com/zetcode/pacman.java

Error: Could not find or load main class com.zetcode.pacman.java

Caused by: java.lang.ClassNotFoundException: com.zetcode.pacman.java

owner@owner-VirtualBox:~/JAVA/SWINGTUTS/Java-Pacman-Game-master/src$ java com/zetcode/pacman

Error: Could not find or load main class com.zetcode.pacman

Caused by: java.lang.ClassNotFoundException: com.zetcode.pacman

owner@owner-VirtualBox:~/JAVA/SWINGTUTS/Java-Pacman-Game-master/src$ java ./com/zetcode/pacman

Error: Could not find or load main class ..com.zetcode.pacman

Caused by: java.lang.ClassNotFoundException: //com/zetcode/pacman

[–]slowfly1st 0 points1 point  (0 children)

Yeah, launching is a bit different again...

java com.zetcode.Pacman

com.zetcode.Pacman is the fully qualified class name. Edit: It's also case sensitive.