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 910173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:59:57+00:00 2026-05-15T16:59:57+00:00

I wanted to share here a useful script of mine. I am developing some

  • 0

I wanted to share here a useful script of mine.
I am developing some java CLI software under Eclipse.
For time to time, I find it useful to run it from the command line with custom arguments (with Cygwin in my case), instead of creating a new “Run configuration” in eclipse.

My eclipse project depends on some other “core” projects and a bunch of libs.

So I needed a bash launcher …

  • 1 1 Answer
  • 1 View
  • 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-15T16:59:58+00:00Added an answer on May 15, 2026 at 4:59 pm

    So here is my solution :

    I used to hardcode this whole CLASSPATH in a launcher script, but it was a pain to maintain.

    So recently, I wrote a bash script that automatically parses the “.classpath” files recursively and generates CLASSPATH dynamically. This way, my launcher is always up to date. I have also added a “debug” option, that launches Java in remote debug mode.

    Hope this helps someone.

    #! /usr/bin/bash
    # Eclipse CLI program launcher.
    
    # ----------------------------------------------------------
    # Constants
    # ----------------------------------------------------------
    
    # Main class
    CLASS=your.main.class.Here
    
    # ----------------------------------------------------------
    # Parse arguments
    # ----------------------------------------------------------
    # Debugger mode ?
    if [ "$1" = "debug" ]
    then
        shift
        DEBUG_OPTIONS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,address=3409,suspend=y"
    fi
    
    # -------------------------------------------------------
    # Setup the classpath from eclipse .classpath files
    # -------------------------------------------------------
    
    # Init classpath
    CLASSPATH=""
    
    # Process a single .classpath file
    # This is a recursive function
    # Arguments:
    #  $1 : Dir path where to search for a ".classpath" file
    function build_classpath() {
    
        # Aliases to arguments
        local folder="$1"
        local file="$folder/.classpath"
    
        # ".classpath" file does not exists ? => exit
        if [ ! -f "$file" ]
        then
            return
        fi
    
        # Parse the file with sed
        # return a list of <type>:<path> pairs
        local lines=`sed -ne 's/^.*kind="\(.*\)"\s\s*path="\(.*\)".*$/\1:\2/gp' $file`
    
        # Loop on lines
        for line in $lines
        do
            # Split the type and path values
            local type=${line%:*}
            local path=${line#*:} 
    
            # Switch on type
            case $type in
    
                "lib" )
                    CLASSPATH=$CLASSPATH:$folder/$path
                    ;;
    
                "output" )
                    CLASSPATH=$CLASSPATH:$folder/$path
                    ;;
    
                "src" )
                    # Recursive call for other projects, relative to the workspace (the parent dir)
                    build_classpath "..$path"
                    ;;
            esac
    
        done
    }
    
    # Start building the classpath from the current project dir
    build_classpath .
    
    # Call java
    java  $DEBUG_OPTIONS -Xmx1024m -cp `cygpath -wp $CLASSPATH` $CLASS $@
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've manually installed the latest Eclipse on our debian server and wanted to configure
Here's the problem I'm trying to solve: I need to be able to display
I'm using jquery to pop up an AddThis share box when I click on
Hi I was wanted to do Application witch have a root template view with
I'm relatively new to Ruby and have limited time therefore I try out simple
I know that variable assignment in python is in fact a binding / re-bindign
Recently I have been working on a project where, among other things, we want
I am doing research about integrating a product into Dynamics Great Plains. I have
I have a problem with an MVC view that I just cannot seem to
Ok, let me start out by saying that I am brand new to MVC.

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.