java - Classes in the same package not communicating with each other -
i started working on snake game, , made main class, , made display class immediately. created package, "game" them, when compile main class, console says can't find "display."
here main class:
package game; public class main { public static display f = new display(); public static int w = 700; public static int h = 400; public static void main( string[] args ) { f.settitle(" snake"); f.setsize(w, h); } // end of method main() } // end of class main
here display class (not completed):
package game; import javax.swing.*; public class display extends jframe { public display() { } // end of constructor } // end of class display
consider directory structure :
project | ------------------------- | | source | build (this compiled stuff go or resources) ------------ | | main.java display.java
now command prompt, go project
directory , write :
javac -d build source\*.java
this create package folders
inside build
folder automatically (in case game
folder created automatically containing display.class
, main.class
). go build
folder , run :
java game.main
more information regarding use of javac
can found, typing javac
on terminal. options javac
can used with, displayed on terminal.
Comments
Post a Comment