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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:28:32+00:00 2026-05-20T12:28:32+00:00

I want to set a path in my Java program with this Windows command

  • 0

I want to set a path in my Java program with this Windows command (this path contains some DLL files that are used in a native peripheral of my program):

c:\>path=%path%;"C:\Users\NetBeansProjects\IPTV1.7\3rd_party"

But this causes an exception when the program runs:

java.io.IOException: Cannot run program “path=%path%;C:\Users\NetBeansProjects\IPTV1.7\3rd_party\”: CreateProcess error=2, The system cannot find the file specified

I don’t know why I can set the path with no problem in the command prompt but then get an exception thrown in the code.

String path = "C:\\Users\\NetBeansProjects\\IPTV1.7\\3rd_party\\";
Runtime rt = Runtime.getRuntime();
Process p = rt.exec("path=%path%;"+ path);
  • 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-20T12:28:33+00:00Added an answer on May 20, 2026 at 12:28 pm

    Your command

    path=%path%;"C:\Users\NetBeansProjects\IPTV1.7\3rd_party"
    

    is not a “real” windows command, but only a variable assignment, interpreted by your shell (cmd.exe), visible only in the same shell session and any commands (other programs) started from there.

    When trying to execute this from Java with Runtime.exec(), the windows CreateProcess function tries to find a executable file with this strange name, which obviously does not exist (can’t exist, I think), and you get this error.

    Even if you could execute this, for example by calling cmd.exe, it would only influence this same cmd.exe process (and any programs started from there, not your own Java process (and programs started from here).

    Depending on what you in fact want, you could, for example:

    • give the path with ProcessBuilder directly to the process which in fact needs it (like Aaron showed)
    • search by yourself for executable files, if you want this for finding commands in the next exec
    • put the variable assignment and other commands together in a .BAT or .CMD file and execute this.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple program. I want to set the path and some properties
I have two projects that I want to share some code, So I set
I have a Java program making some JNI calls to a native library (mylib.so).
In a Java project, I am using a third-party library that loads some native
I got a native library that needs to be added to java.library.path . With
Hi I want to set dynamic path to my picture box in winforms. Is
I want to set configuration variable (path, in particular) in CMakeList.txt for my project,
I want to put path of different directory (which contains jars, presently on d:/ext_jars
I'm new to Java, and have set myself a project to write so that
I have a program that resides in a directory that is not set in

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.