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

  • SEARCH
  • Home
  • 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 5959503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:41:38+00:00 2026-05-22T18:41:38+00:00

Grape seems to work fairly well for adding jars to your classpath. It also

  • 0

Grape seems to work fairly well for adding jars to your classpath. It
also does a lot of other things such as fetching and dependency management.
e.g.

#!/home/robert/bin/groovy

import org.apache.commons.lang.StringUtils

@Grab(group='commons-lang', module='commons-lang', version='2.4')

def strings = ['Hello', 'Groovy', 'AVeryLongWord!', 'A simple sentence']
strings.each { String aString ->
    println "$aString: ${StringUtils.abbreviate(aString,10)}"
}

Unfortunately if there is a jar on my filesystem that I want to
dynamically add to the filesystem then I have to resort to a much
uglier solution.

#!/home/robert/bin/groovy

def loader = this.class.classLoader.rootLoader
loader.addURL(new File("/home/robert/somejars/arithmetic-1.1.jar").toURI().toURL())

// can't use traditional package import
arithmeticMainClass = Class.forName("org.scharp.arithmetic.Main")

println "42 - 23 = " + arithmeticMainClass.subtract(42, 23)

// can't use "new" operator
myArithmeticObject = arithmeticMainClass.newInstance()

Is there a way to make grape grab a jar from the filesystem? If not,
can I somehow replicate what grape is doing in groovy/java?

I would like this solution to work for scripts that can be run by many users and many incompatible jars so adding jars to a common directory such as ~/.groovy/lib/ won’t work.

I could create a local maven repository for local, jar libaries but
that seems like overkill.

  • 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-22T18:41:39+00:00Added an answer on May 22, 2026 at 6:41 pm

    There’s been some interest in adding this feature to grape but nothing serious. My guess is that it’s unlikely that this will be added in the near future. (6-18 months)

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

Sidebar

Related Questions

Suppose I have a column with words: orange grape orange orange apple orange grape
It seems WindowEvent.WINDOW_SHOWN never gets dispatched on any of the nodes in the scene
So I'm trying to work my way through this paper , which is primarily
How do map providers (such as Google or Yahoo! Maps) suggest directions? I mean,
I have a program that is constantly running. Normally, it seems to garbage collect,
I'd like to use @Grape in my groovy program but my program consists of
I usually install R packages using the command below, but it will not work
I can't seem to get the Facebook Graph API to work in IE7, IE8,
I'm trying to work out an algorithm for finding a path across a directed
I work on a game project. Recently, we run into a problem which we

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.