Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6158305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:56:06+00:00 2026-05-23T20:56:06+00:00

I’m developing a Groovy shell script which is launched frequently (doing rather small tasks),

  • 0

I’m developing a Groovy shell script which is launched frequently (doing rather small tasks), therefore I need a fast JVM startup time. To achieve that I’m trying to launch it with Nailgun.

I have installed Nailgun as an Ubuntu package. Then I fixed the argument bug by linking /usr/bin/ng-server to /usr/bin/ng. I’m starting the Nailgun-Server like this:

java -cp /usr/share/java/nailgun-0.7.1.jar -server com.martiansoftware.nailgun.NGServer

I have this simple dummy Groovy script named hello.groovy just to test the nailgun-server:

#!/usr/bin/env groovy
def sayHello() {
  println("Hello Groovy!");
}

sayHello();

I compiled the file with groovyc to hello.class.

Now I want to launch that script within the Nailgun server. My naive approach to do that would be:

ng hello
ng hello.sayHello

But all I get are ClassNotFoundExceptions:

java.lang.ClassNotFoundException: hello
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at com.martiansoftware.nailgun.NGSession.run(Unknown Source)

So, what is the right way to launch my Groovy script with the Nailgun Server? I’d also appreciate some good sites/tutorials about how to use Nailgun, it’s really hard to get any information how to use it…

EDIT:

I would also appreciate a complete example (including how a specific class is called with ng) for using nailgun with pure Java classes, as I could also not get ng working with any Java class.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:56:07+00:00Added an answer on May 23, 2026 at 8:56 pm

    Finally got it. I just did not understand that I have to add all needed classes to the Nailgun classpath first (this SO question gave me the final hints).

    First, add Groovy to the classpath:

    ng ng-cp /usr/share/java/groovy-all.jar
    

    Then add the directory which contains the Groovy script/Java class to the classpath, in my case it’s:

    ng ng-cp /home/$USER/tools/groovy
    

    Now I can run my Groovy script with Nailgun like this:

    ng hello
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.