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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:36:56+00:00 2026-06-09T15:36:56+00:00

I am developing two Java applications in Netbeans, and I need to run the

  • 0

I am developing two Java applications in Netbeans, and I need to run the second app in the first one. I do this using the following code:

ProcessBuilder pb = new ProcessBuilder("java", "Second App Main Class Name");
pb.start();

The problem is that the second app has a huge number of dependencies which I added as references in Netbeans. But when I run it using above code, Java obviously finds non of them.

Since my project uses lots of Libraries, can I handle all the Classpath automatically somehow?

  • 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-06-09T15:36:57+00:00Added an answer on June 9, 2026 at 3:36 pm

    Well, the problem here is that you don’t really have a classpath configured in the environment for your second Java application, so even though you can invoke the main class itself (as you said,) none of the other dependencies are found.

    I’d also guess that even if you use something like Maven or Ant, if you are building two separate Java applications with separate classpaths (but one knows about the other’s classpath, then you could do something like this in order to tell the ProcessBuilder how to find the right JAR and Class files for your second application:

    public int exec(Class<?> clazz) throws IOException,
                                               InterruptedException {
        String javaHome = System.getProperty("java.home");
        String javaBin = javaHome +
                File.separator + "bin" +
                File.separator + "java";
    
        /* This is where you want to set up your Classpath for the second app */
        String classpath = System.getProperty("java.class.path");
        String className = clazz.getCanonicalName();
    
        ProcessBuilder builder = new ProcessBuilder(
                javaBin, "-cp", classpath, className);
    
        Process process = builder.start();
        process.waitFor();
        return process.exitValue();
    }
    

    But I question why you are launching the app from NetBeans – assumedly you will need to eventually launch both apps from the command line. If you can’t launch the apps from the command-line, then you won’t be able to launch them from Java either. ProcessBuilder just behaves as a command-line launcher for other programs on the system.

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

Sidebar

Related Questions

I am developing two java programs that run in separate VM's that have a
I am developing a small desktop application in JAVA using Netbeans. I place a
For the Java app I am currently developing I am using an ID system,
I'm developing a Java application using Eclipse. My project has two source directories that
I am developing an Twitter4J web application in Google App Engine/Java. I need to
I am developing a Java webservice application (with JAX-WS) that has to use two
I'm developing two Ruby gems, one is a framework, the other is an application.
I'm new to magento. Currently i'm developing two ecommerce sites using multi-store option in
I'm developing a menu that has two modes, when the user clicks on one
Im developing the java Email application with Timer, I have a two arraylists named

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.