Take the 2-minute tour ×
    package mainClasses;
     * Frame Info and all that ****,
     * mainFrame is the actual frame itself
     * it will refer to MainC.java a lot Main class = Main Class
    import java.awt.FlowLayout;
    import java.awt.Graphics;
    import JavaGame.src.resources.*; //Problem Code
    import javax.swing.JButton;
    import javax.swing.JFrame;

    public class mainFrame extends JFrame {

private static final long serialVersionUID = 1L;

public mainFrame() {
    JButton playButton = new JButton();
    JButton infoButton = new JButton();
    JButton exitButton = new JButton();
    int x = 300, y = 300;
    setSize(x, y);
    setLayout(new FlowLayout());
    setTitle("Kingdom Raider");

    /*Buttons and Properties*/

     playButton.setBounds(x, y, 200, 100);

     infoButton.setBounds(x, y, 200, 100);

     exitButton.setBounds(x, y, 200, 100);
            /* Add image here */


public void Painting (Graphics g) {

Well thats my code. Now to explain the Problem. So basically, im creating a game (or at least trying to) and im having a import Problem. As you can see i want to import JavaGame.src.resources, as im trying to import an img. Heres how my Directory stands:

As im new, i cant post images: so heres the LINK: http://i.imgur.com/e5qkB.jpg

![Directory][1] *Dont need to know the code on resourcesmanager.java its blank atm. So basically, this class here is in packages mainClasses, but i want to access the resources package. What gives? Please help me.

share|improve this question
The package name is just resources, the src folder and JavaGame folder aren't included –  Hunter McMillen Apr 23 '12 at 15:16
add comment

5 Answers

Your package name is resources, so write this:

import resources.*; // No-Problem Code

The remaining parts of the directory structure is specific to Eclipse and doesn't have anything to do with Java classpaths

share|improve this answer
Didnt work. Still says invalid import –  The One that asks alot Apr 23 '12 at 15:20
Hmm, that would be weird. Can you post more info? From your screenshot that should be sufficient... –  Lukas Eder Apr 23 '12 at 15:24
add comment

Your source folder is src, so this is the root of your class hierarchy. You should do

import resources.*

However using * is bad form and you should try and import only classes that you need in this particular class, like you've done with javax.swing.JButton for example. So:

import resources.ResourceManager;
share|improve this answer
add comment

Resources aren't imported like packages. Have a look here: http://docs.oracle.com/javase/1.5.0/docs/guide/lang/resources.html.

Specifically, here's an example how to load images from resources: http://docs.oracle.com/javase/tutorial/uiswing/components/icon.html#getresource.

share|improve this answer
Fair point, but there's nothing wrong with having resources on the classpath. –  maksimov Apr 23 '12 at 15:19
add comment

Eclipse will automatically import stuff for you if you copy and paste something-maybe you could write a short clip that uses something in JavaGame.src.resources, and then copy paste that-eclipse will do the rest.

share|improve this answer
add comment

I think this could be a problem with Eclipse configuration. Sometimes Eclipse considers the source folder in the project as part of the package. Just delete the project from the Eclipse workspace without deleting it from the file system and import it again.

That should help.

Deleting project from eclipse without deleting it from the file system:


Importing existing project into eclipse:


share|improve this answer
add comment

Your Answer


