(Java) package does not exist

Discussion in 'Mac Programming' started by Avicenna, Mar 18, 2011.

  1. Avicenna, Mar 18, 2011
    Last edited by a moderator: Mar 18, 2011

    Avicenna macrumors member

    Jul 16, 2009
    I am new to Java. I am trying to use a class (AudioFile) that is located in the folder org ->jaudiotagger -> audio. My main class is running from the same directly as the folder org is located in. I am importing the package but when I try to compile it gives me package does not exist error. You can see the entire layout of the files, my Main class and the error produced below:


  2. jiminaus macrumors 65816


    Dec 16, 2010
    Do this
    cd ~/Desktop/MP3AlbumArt
    before doing this
    javac Main.java
    Then you'll be able to successfully run it too with
    java Main
  3. Avicenna thread starter macrumors member

    Jul 16, 2009
    Hey thanks for the input but it's still not working. It tells me that it could not find the symbol audio file. But if I address AudioFile as org.jaudiotagger.audio.AudioFile then it works, but this name is too long. Is there a way I can just call it AudioFle?

    I am importing org.jaudiotagger.*;
  4. Mac Player macrumors regular

    Jan 19, 2006

  5. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    That's not what your code says. This is your code:
    [COLOR="Red"]import org.jaudiotagger.audio;
    public class Main {
      public static void main(String[] args) {
        AudioFile f = new AudioFile();
    The red-hilited statement imports a single class named 'audio' located in the package org.jaudiotagger. Since no such class exists, the import fails.

    Fix your import statement and the reference to the AudioFile class will work. The import should be:
    import org.jaudiotagger.audio.*;
    Sub-packages or super-packages must be imported separately. Imports are not hierarchical. The ".*" only imports classes in that single package. It does not import any sub-packages or super-packages. For example, to get the FileConstants class you need one of these:
    import org.jaudiotagger.FileConstants;
    import org.jaudiotagger.*;

    For future reference, posting a giant picture is a poor way to show code. Post actual code, as copied and pasted text. Do not post pictures of code.

    You should copy and paste the text of error messages, too, rather than pictures of them.

Share This Page