Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.