Dobrý den, mám kód:
import java.io.*;
import net.sf.jmimemagic.Magic;
import net.sf.jmimemagic.MagicException;
import net.sf.jmimemagic.MagicMatch;
import net.sf.jmimemagic.MagicMatchNotFoundException;
import net.sf.jmimemagic.MagicParseException;
public class Mime {
public static String getMime(byte[] bytes) {
Magic parser = new Magic() ;
try {
MagicMatch match = parser.getMagicMatch(bytes);
System.out.println(match.getMimeType()) ;
}
catch(Exception e) {
System.out.println("nazdar");
}
return "nazdar";
}
public static void main(String[] args) throws IOException {
File soubor = new File("/home/neithan/ukazka.png");
FileInputStream stream = new FileInputStream(soubor);
byte[] bytes = new byte[(int) soubor.length()];
stream.read(bytes);
try {
Mime.getMime(bytes);
}
catch(Exception e) {
}
}
}
Ale, když spouštím java Mime tak mi to hlási toto:
neithan@neithan-desktop:~/java/ImageResize/src$ javac -classpath /home/neithan/Desktop/jmimemagic-0.1.1.jar Mime.java
neithan@neithan-desktop:~/java/ImageResize/src$ java Mime
Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/jmimemagic/Magic
at Mime.getMime(Mime.java:11)
at Mime.main(Mime.java:33)
Caused by: java.lang.ClassNotFoundException: net.sf.jmimemagic.Magic
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 2 more
Kde jsem udělal chybu, že to nefunguje?