Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Avicenna

macrumors member
Original poster
Jul 16, 2009
89
0
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:

2mqme0o.png


Thanks!
 
Last edited by a moderator:
Do this
Code:
cd ~/Desktop/MP3AlbumArt
before doing this
Code:
javac Main.java

Then you'll be able to successfully run it too with
Code:
java Main
 
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.*;
 
I am importing org.jaudiotagger.*;

That's not what your code says. This is your code:
Code:
[COLOR="Red"]import org.jaudiotagger.audio;
[/COLOR]
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:
Code:
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:
Code:
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.