2

How do I run a jar file?

I tried this : java iCChecker.jar

but I got next trace :

Exception in thread "main" java.lang.NoClassDefFoundError: iCChecker/jar
Caused by: java.lang.ClassNotFoundException: iCChecker.jar
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: iCChecker.jar.  Program will exit.

So, what am I doing wrong? And how to start this jar file?

1 Answer 1

5

To run a jar file, pass the -jar option to java. Otherwise it assumes the given argument is the name of a class, not the name of a jar file (specifically in this case it's looking for a class named jar in a the package iCChecker).

So java -jar iCChecker.jar will work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .