LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   executing jar (groovy language) (https://www.linuxquestions.org/questions/programming-9/executing-jar-groovy-language-804088/)

john83reuben 04-25-2010 10:33 AM

executing jar (groovy language)
 
Hi experts,

I have a problem executing a jar file. Its in groovy language.

My two classes:
TestRunnerScript.class
TestRunner.class

Manifest:
Main-Class: TestRunnerScript

So I successfully made it a jar file by executing jar -cvmf manifest.txt iltester.jar *.class

When I want to execute the jar file with this command java -jar iltester.jar, i get the following error

Code:

Exception in thread "main" java.lang.NoClassDefFoundError: groovy/lan
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(Unknown Source)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(Unknown Source)
        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)
Caused by: java.lang.ClassNotFoundException: groovy.lang.Script
        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)
        ... 12 more
Could not find the main class: TestRunnerScript. Program will exit.


and when i did this

Quote:

java -cp C:\Program Files\Groovy\Groovy-1.7.1\embeddab
le\groovy-all-1.7.1.jar; iltester.jar
i get the following error

Code:

Exception in thread "main" java.lang.NoClassDefFoundError: Files\Groovy\Groovy-1
/7/1\embeddable\groovy-all-1/7/1/jar;
Caused by: java.lang.ClassNotFoundException: Files\Groovy\Groovy-1.7.1\embeddabl
e\groovy-all-1.7.1.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)
Could not find the main class: Files\Groovy\Groovy-1.7.1\embeddable\groovy-all-1
.7.1.jar;.  Program will exit.


Can anyone tell me where did i made the mistake. Cause i couldnt able to run the jar file.

If i execute the classes separately, it can be executed. Only problem is in jar file.

Thanks in advance

John

jcomeau_ictx 05-21-2010 08:48 PM

I'm not familiar with 'groovy' but have experience with jarfiles. The first problem is that you need all your 'groovy' stuff to be in the jarfile, unless you tell it where to find them with -cp (classpath). In the second case, you gave it a classpath but didn't put quotes around it so it took the space between "Program Files" as the end of the classpath. And you still need to specify "-jar iltester.jar" after the classpath:

java -cp "C:\Program Files\Groovy\Groovy-1.7.1\embeddable\groovy-all-1.7.1.jar;iltester.jar" -jar iltester.jar

Note no spaces in classpath either, unless they're part of the filename.


All times are GMT -5. The time now is 10:42 PM.