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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:36:48+00:00 2026-05-28T15:36:48+00:00

Is there a way to launch a java class (and pass it a classpath

  • 0

Is there a way to launch a java class (and pass it a classpath and libary path) from within a Java application with out using Runtime.exec?

I have seen:
Launch a java application from another java application

but need to be able to pass a CLASSPATH and libary path.

I am trying to make a launcher that a user downloads, it downloads the required files and then launches them.

Thank You

  • 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-28T15:36:49+00:00Added an answer on May 28, 2026 at 3:36 pm

    https://stackoverflow.com/a/5575619/20394 should explain how to add to the library path and still use the same JVM.

    To add to the classpath, create your own URLClassLoader and use that to find the class you want to load, then call its start method reflectively.

    URLClassLoader classLoader = new URLClassLoader(
        urlsToDirectoriesAndJars, getClass().getClassLoader());
    Class<?> myMainClass = classLoader.findClass("pkg.path.for.MainClass");
    Method main = myMainClass.getMethod("main", String[].class);
    main.invoke(null, new Object[] { new String[] { "args", "for", "main" } });
    

    You’ll need to handle some exceptions that are thrown by the reflective API but that’s the gist of it.

    If that class calls System.exit, then see How to prevent calls to System.exit() from terminating the JVM?

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

Sidebar

Related Questions

Is there a way to launch a gnome-terminal from the command line (i.e., using
I'm trying to launch another application from C# application, is there a way to
Is there a way to launch methods written in Java from Eclipse without having
Is there a way to launch a C# application with the following features? It
Is there any way to automatically launch an application on USB attach or CD
You launch a java program from a console (maybe using a .bat script). I
In Java 5, is there a default way to pass a URL to the
Is there a way to have a Java process either fork or launch another
Possible Duplicate: Is there a way to the hide win32 launch console from a
Is there any way to launch a program with a shortcut, that sets the

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.