Page 1 of 2 12 LastLast
Results 1 to 20 of 33
Like Tree1Likes

Thread: A problem with the import part

  1. #1
    gyijhbk is offline Member
    Join Date
    Feb 2012
    Posts
    61
    Rep Power
    0

    Default A problem with the import part

    When I try to import a class it says: error: cannot find symbol.I am sure about the path of the class and the name.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: A problem with the import part

    Please post the full text of the error message and the source where the error occurs.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    gyijhbk is offline Member
    Join Date
    Feb 2012
    Posts
    61
    Rep Power
    0

    Default Re: A problem with the import part

    import java.io.someclass1;
    import java.io.someclass2;
    import java.io.someclass3;
    import java.lang.String;
    import java.io.*;

    keyboard.java:2: error: cannot find symbol
    import java.io.someclass1;
    ^
    symbol: class GlobalKeyListener
    location: package java.io
    keyboard.java:3: error: cannot find symbol
    import java.io.someclass2;
    ^
    symbol: class KeyAdapter
    location: package java.io
    keyboard.java:4: error: cannot find symbol
    import java.io.someclass3;
    ^
    symbol: class KeyEvent
    location: package java.io
    the classеs are there.

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,730
    Blog Entries
    7
    Rep Power
    21

    Default Re: A problem with the import part

    Is there a class 'someclass1' in the java.io pacakge? I didn't know that.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    gyijhbk is offline Member
    Join Date
    Feb 2012
    Posts
    61
    Rep Power
    0

    Default Re: A problem with the import part

    This is a class which i added to java.io pacakge

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,730
    Blog Entries
    7
    Rep Power
    21

    Default Re: A problem with the import part

    Quote Originally Posted by gyijhbk View Post
    This is a class which i added to java.io pacakge
    You can't do that; the jar where the java.io classes are stored, is sealed.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    gyijhbk is offline Member
    Join Date
    Feb 2012
    Posts
    61
    Rep Power
    0

    Default Re: A problem with the import part

    But then how i can add/change classes in java.io ? before there was not a problem.

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: A problem with the import part

    Extend them to make your own class.
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    gyijhbk is offline Member
    Join Date
    Feb 2012
    Posts
    61
    Rep Power
    0

    Default Re: A problem with the import part

    Ok now I have another error:
    import de.ksquared.test.system.keyboar.*;
    import de.ksquared.system.keyboard.GlobalKeyListener;
    import de.ksquared.system.keyboard.KeyAdapter;
    import de.ksquared.system.keyboard.KeyEvent;

    package de.ksquared.test.system.keyboard;


    public class KeyboardHookTest {
    public static void main(String[] args) {
    new GlobalKeyListener().addKeyListener(new KeyAdapter() {
    @Override public void keyPressed(KeyEvent event) { System.out.println(event); }
    @Override public void keyReleased(KeyEvent event) {
    System.out.println(event);
    if(event.getVirtualKeyCode()==KeyEvent.VK_ADD
    && event.isCtrlPressed())
    System.out.println("CTRL+ADD was just released (CTRL is still pressed)");
    }
    });
    while(true)
    try { Thread.sleep(100); }
    catch(InterruptedException e) { e.printStackTrace(); }
    }
    }


    D:\project>javac KeyboardHookTest.java
    KeyboardHookTest.java:6: error: class, interface, or enum expected
    package de.ksquared.test.system.keyboard;
    ^
    1 error

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: A problem with the import part

    The package statement goes first.
    If you don't understand my response, don't ignore it, ask a question.

  11. #11
    gyijhbk is offline Member
    Join Date
    Feb 2012
    Posts
    61
    Rep Power
    0

    Default Re: A problem with the import part

    Ok now I got this:
    KeyboardHookTest.java:4: error: package de.ksquared.test.system.keyboar does not
    exist
    import de.ksquared.test.system.keyboar.*;
    ^
    KeyboardHookTest.java:5: error: package de.ksquared.system.keyboard does not exi
    st
    import de.ksquared.system.keyboard.GlobalKeyListener;
    ^
    KeyboardHookTest.java:6: error: package de.ksquared.system.keyboard does not exi
    st
    import de.ksquared.system.keyboard.KeyAdapter;
    ^
    KeyboardHookTest.java:7: error: package de.ksquared.system.keyboard does not exi
    st
    import de.ksquared.system.keyboard.KeyEvent;
    ^
    KeyboardHookTest.java:13: error: cannot find symbol
    new GlobalKeyListener().addKeyListener(new KeyAdapter() {
    ^
    symbol: class KeyAdapter
    location: class KeyboardHookTest
    KeyboardHookTest.java:13: error: cannot find symbol
    new GlobalKeyListener().addKeyListener(new KeyAdapter() {
    ^
    symbol: class GlobalKeyListener
    location: class KeyboardHookTest

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: A problem with the import part

    Are the definitions for those packages on the classpath? The compiler can not find them. What is on the classpath when you try to compile?
    If you don't understand my response, don't ignore it, ask a question.

  13. #13
    gyijhbk is offline Member
    Join Date
    Feb 2012
    Posts
    61
    Rep Power
    0

    Default Re: A problem with the import part

    Nothing it is by default

  14. #14
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: A problem with the import part

    It needs to point to the folder that contains the folder at the start of the package: de
    If you don't understand my response, don't ignore it, ask a question.

  15. #15
    gyijhbk is offline Member
    Join Date
    Feb 2012
    Posts
    61
    Rep Power
    0

    Default Re: A problem with the import part

    and again...
    D:\project>javac -classpath "C:\Program Files\Java\lib\de" KeyboardHookTest.java

    KeyboardHookTest.java:4: error: package de.ksquared.test.system.keyboar does not
    exist
    import de.ksquared.test.system.keyboar.*;
    ^
    KeyboardHookTest.java:5: error: package de.ksquared.system.keyboard does not exi
    st
    import de.ksquared.system.keyboard.GlobalKeyListener;
    ^
    KeyboardHookTest.java:6: error: package de.ksquared.system.keyboard does not exi
    st
    import de.ksquared.system.keyboard.KeyAdapter;
    ^
    KeyboardHookTest.java:7: error: package de.ksquared.system.keyboard does not exi
    st
    import de.ksquared.system.keyboard.KeyEvent;
    ^
    KeyboardHookTest.java:13: error: cannot find symbol
    new GlobalKeyListener().addKeyListener(new KeyAdapter() {
    ^
    symbol: class KeyAdapter
    location: class KeyboardHookTest
    KeyboardHookTest.java:13: error: cannot find symbol
    new GlobalKeyListener().addKeyListener(new KeyAdapter() {
    ^
    symbol: class GlobalKeyListener
    location: class KeyboardHookTest
    6 errors

  16. #16
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: A problem with the import part

    I said: It needs to point to the folder that contains the folder at the start of the package: de

    "C:\Program Files\Java\lib\de"
    Does the folder de contain a folder de?
    If you don't understand my response, don't ignore it, ask a question.

  17. #17
    gyijhbk is offline Member
    Join Date
    Feb 2012
    Posts
    61
    Rep Power
    0

    Default Re: A problem with the import part

    It is the same.
    D:\project>javac -classpath "C:\Program Files\Java\lib" KeyboardHookTest.java
    KeyboardHookTest.java:4: error: package de.ksquared.test.system.keyboar does not
    exist
    import de.ksquared.test.system.keyboar.*;
    ^
    KeyboardHookTest.java:5: error: package de.ksquared.system.keyboard does not exi
    st
    import de.ksquared.system.keyboard.GlobalKeyListener;
    ^
    KeyboardHookTest.java:6: error: package de.ksquared.system.keyboard does not exi
    st
    import de.ksquared.system.keyboard.KeyAdapter;
    ^
    KeyboardHookTest.java:7: error: package de.ksquared.system.keyboard does not exi
    st
    import de.ksquared.system.keyboard.KeyEvent;
    ^
    KeyboardHookTest.java:13: error: cannot find symbol
    new GlobalKeyListener().addKeyListener(new KeyAdapter() {
    ^
    symbol: class KeyAdapter
    location: class KeyboardHookTest
    KeyboardHookTest.java:13: error: cannot find symbol
    new GlobalKeyListener().addKeyListener(new KeyAdapter() {
    ^
    symbol: class GlobalKeyListener
    location: class KeyboardHookTest
    6 errors

  18. #18
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: A problem with the import part

    How about waiting on this complicated project and writing a small simple program that uses one class in a package that is in a folder. When you get that to work, then move on to this more complicated project.

    There are so many things you could have set up incorrectly that chasing them all down is going to take too long. Start with a simple project.
    If you don't understand my response, don't ignore it, ask a question.

  19. #19
    gyijhbk is offline Member
    Join Date
    Feb 2012
    Posts
    61
    Rep Power
    0

    Default Re: A problem with the import part

    ok.Some suggestions>

  20. #20
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,730
    Blog Entries
    7
    Rep Power
    21

    Default Re: A problem with the import part

    Quote Originally Posted by gyijhbk View Post
    ok.Some suggestions>
    Read reply #18 again.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Page 1 of 2 12 LastLast

Similar Threads

  1. problem in java import
    By black300 in forum New To Java
    Replies: 2
    Last Post: 04-05-2011, 08:56 AM
  2. Problem import query.*
    By teaicky in forum New To Java
    Replies: 4
    Last Post: 02-06-2011, 12:09 AM
  3. Problem with import libraries
    By sarwar1234 in forum New To Java
    Replies: 3
    Last Post: 09-21-2010, 11:38 AM
  4. MultiThreading Problem part 2
    By ravjot28 in forum New To Java
    Replies: 33
    Last Post: 03-11-2010, 07:22 PM
  5. import problem
    By anki.gulsvart in forum Networking
    Replies: 9
    Last Post: 10-16-2009, 08:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •