LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-25-2010, 10:33 AM   #1
john83reuben
Member
 
Registered: Oct 2007
Location: Kuala Lumpur,Malaysia
Distribution: Debian Etch, OpenSuse
Posts: 132

Rep: Reputation: 17
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
 
Old 05-21-2010, 08:48 PM   #2
jcomeau_ictx
LQ Newbie
 
Registered: Aug 2004
Location: Petaluma, CA, US
Distribution: Debian GNU/Linux squeeze/sid
Posts: 29

Rep: Reputation: 17
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
groovy scripting advice john83reuben Programming 1 03-07-2010 07:44 PM
How to set mail.jar(JavaMail) and mysql-connector-java.jar in Linux class path Terry56 Linux - Software 3 01-19-2010 09:06 AM
Want to take a Backup as jar and upload jar to other server LearnUnix Linux - Newbie 4 10-30-2009 04:48 AM
I got error with this command 'java -jar NodeView-v1.1.jar' mohdismiaswaly Linux - Software 3 04-23-2009 06:24 AM
Fedora Core 1 Associating .jar files with java -jar command pymehta Fedora 0 01-13-2005 05:26 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration