473,387 Members | 1,318 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Can't get my package to work: "package graphics does not exist"

Hello! I don't know how to get my package to work. Ineed help to get access to my Screen file.

I have created a folder called "spel", and in that folder I have 2 subfolders, the first subfolder is called "rain" and inside it I have the class file "Game". The second subfolder is called "graphics", and inside that I have my class file "Screen".

Please, it would make me so happy to know what I'm doing wrong.


Expand|Select|Wrap|Line Numbers
  1. class Game: 
  2. -----------------------------
  3. package spel;
  4.  
  5. import graphics.Screen;
  6. import java.awt.Canvas;
  7. import java.awt.Color;
  8. import java.awt.Dimension;
  9. import java.awt.Graphics;
  10. import java.awt.image.BufferStrategy;
  11. import java.awt.image.BufferedImage;
  12. import java.awt.image.DataBufferInt;
  13.  
  14. import javax.swing.JFrame;
  15.  
  16. public class Game extends Canvas implements Runnable {
  17.  
  18.     private static final long serialVersionUID = 1L;
  19.  
  20.     public static int width = 300;
  21.     public static int height = width/16*9;
  22.     public static int scale = 3;
  23.  
  24.     private Thread thread;
  25.     private JFrame frame;
  26.     private boolean running = false;
  27.  
  28.     private Screen screen;
  29.  
  30.     private BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 
  31.     private int [] pixels = ((DataBufferInt)image.getRaster().getDataBuffer()).getData(); 
  32.  
  33.     public Game() {
  34.  
  35.         Dimension size = new Dimension(width * scale, height * scale);
  36.         setPreferredSize(size);
  37.  
  38.         frame = new JFrame();
  39.  
  40.     }
  41.  
  42.     public synchronized void start() {
  43.  
  44.         running = true;
  45.         thread = new Thread(this, "Display");
  46.         thread.start();
  47.  
  48.     }
  49.  
  50.     public synchronized void stop(){
  51.  
  52.         running = false;
  53.  
  54.         try {
  55.             thread.join();
  56.         }catch(InterruptedException e){
  57.             e.printStackTrace();
  58.         }
  59.  
  60.     }
  61.  
  62.     public void run() {
  63.  
  64.         while(running) {
  65.  
  66.             update();
  67.             render();
  68.  
  69.         }
  70.  
  71.     }
  72.  
  73.     public void update() {
  74.  
  75.  
  76.     }
  77.  
  78.     public void render() {
  79.  
  80.         BufferStrategy bs = getBufferStrategy(); 
  81.         if (bs == null) {
  82.  
  83.             createBufferStrategy(3); 
  84.             return;
  85.  
  86.         }
  87.  
  88.         Graphics g = bs.getDrawGraphics();
  89.         g.setColor(Color.BLACK);
  90.         g.fillRect(0, 0, getWidth(),   getHeight());
  91.  
  92.         g.dispose(); 
  93.         bs.show();
  94.  
  95.     }
  96.  
  97.     public static void main(String[]args) {
  98.  
  99.         Game game = new Game();
  100.         game.frame.setResizable(false);
  101.         game.frame.setTitle("Rain");
  102.         game.frame.add(game);
  103.         game.frame.pack();
  104.         game.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  105.         game.frame.setLocationRelativeTo(null); 
  106.         game.frame.setVisible(true);
  107.  
  108.         game.start();
  109.  
  110.     }
  111.  
  112. }
  113.  
  114. class Screen:
  115. -----------------------------
  116.  
  117. package spel;
  118.  
  119. //https://www.youtube.com/watch?v=fPSJnzA0nLY = Här är du!
  120.  
  121.  
  122. public class Screen {
  123.  
  124.     private int width;
  125.     private int height;
  126.     public int [] pixels;
  127.  
  128.     public Screen(int width, int height) {
  129.  
  130.         this.width = width;
  131.         this.height = height;
  132.  
  133.     }
  134.  
  135. }
  136.  
  137. -----------------------------
  138.  
  139. Error:
  140. Game.java:4: error: package graphics does not exist
  141. import graphics.Screen;
  142.                ^
  143. Game.java:27: error: cannot find symbol
  144.     private Screen screen;
  145.             ^
  146.   symbol:   class Screen
  147.   location: class Game
  148. 2 errors
Jan 29 '16 #1
1 1921
chaarmann
785 Expert 512MB
I believe this is a problem with your classpath.
Have you added your two folders to it?
Just verify with typing "set" in a cmd-window under windows, or typing "env" in a unix shell.
Feb 2 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Steve | last post by:
Hi, This is my first experiience packaging using the distutils package. I can't figure out how to create a rpm package with disutils that does not contain the source .py files ?? Regards Steve
10
by: Nick L | last post by:
I'm working on a function which creates a pointers to an array of unsigned ints based off a number read from a file. I then continue to read file names from the file, convert the name to a char*...
2
by: Steve Drake | last post by:
All, I have a servicedcomponet that works fine if its activated as library app, but doesn't work if its activated as a server component. I get the following error : ...
1
by: MilanB | last post by:
Hello I want to make some browser application, where user can draw lines, circles and others shapes. (Like small corel draw). How to do this in asp.net? Should I use javascript or which is the...
0
by: memanwar | last post by:
Throughout our system we use the DataGrid. One problem we've noticed is that the arrow buttons don't always work with our grids, clicking on them sometimes won't move the columns at all, or may...
1
by: TVR Fan | last post by:
I've just fixed what should be a bug in a simple function to log a message to a file. The thing is, the original code worked! Protected Sub LogMessage(ByVal filename As String, ByVal message As...
2
by: falconite | last post by:
In a perl script, I'm reading in data from a mysql server database that has some fields that could be millions of bytes long (DNA sequences). However, I am interested only in the first 1000 or so...
3
by: tjstewart | last post by:
I have a form that needs to post data for display on the next page. The form works perfectly using HTTP, but now that I'm trying to use HTTPS the form will connect and then wait until it times out. ...
4
by: Hero Doug | last post by:
A friennd and I were talking about OS development last night and a few questions were raised that need some clarification. I did the usual search and it turned up the usual garbage, so I'm hoping...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.