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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:28:03+00:00 2026-05-11T18:28:03+00:00

I am writing a program that needs to run a java.jar server. I need

  • 0

I am writing a program that needs to run a java.jar server. I need to run the process directly so I can rewrite the output to a textbox and all-in-all have complete control of it. I tried just doing it through CMD.exe, but that wouldnt work because CMD.exe would just call a new process java.exe and I wouldn’t have control of it. I need to call java.exe directly so I can have the control and get the output. Can any of you tell me how to convert this command so I could create a process in C# and call it?

I need this CMD command converted:

“java -Xmx1024m -cp ./../libs/*;l2jserver.jar net.sf.l2j.gameserver.GameServer”

into

a command line I can put into the Process.Arguments so I can call Java.exe directly.

I’ve tried to do it… and it just won’t work.

I’ve been looking at this for hours and hours… please someone help!

  • 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-11T18:28:04+00:00Added an answer on May 11, 2026 at 6:28 pm

    Part of the problem might be that despite what the Framework documentation says using Process doesn’t always resolve things against the PATH environment variable properly. If you know the name of the folder Java is in then use the full path to Java.exe, otherwise use a function like the following:

        private void LocateJava()
        {
            String path = Environment.GetEnvironmentVariable("path");
            String[] folders = path.Split(';');
            foreach (String folder in folders)
            {
                if (File.Exists(folder + "java.exe"))
                {
                    this._javadir = folder;
                    return;
                } 
                else if (File.Exists(folder + "\\java.exe")) 
                {
                    this._javadir = folder + "\\";
                    return;
                }
            }
        }
    

    It’s somewhat hacky but it will find java.exe provided the Java Runtime is installed and it’s folder is in the windows PATH variable. Make a call to this function the first time your program needs to find Java and then subsequently start Java using the following:

       //Prepare the Process
       ProcessStartInfo start = new ProcessStartInfo();
       if (!_javadir.Equals(String.Empty)) {
            start.FileName = this._javadir + "java.exe";
       } else {
            start.FileName = "java.exe";
       }
       start.Arguments = "-Xmx1024m -cp ./../libs/*;l2jserver.jar net.sf.l2j.gameserver.GameServer";
       start.UseShellExecute = false;
       start.RedirectStandardInput = true;
       start.RedirectStandardOutput = true;
    
       //Start the Process
       Process java = new Process();
       java.StartInfo = start;
       java.Start();
    
       //Read/Write to/from Standard Input and Output as required using:
       java.StandardInput;
       java.StandardOutput;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 115k
  • Answers 115k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think you have 3 options: Change the config of… May 11, 2026 at 10:23 pm
  • Editorial Team
    Editorial Team added an answer Just like with debugging, profiling is a task best done… May 11, 2026 at 10:23 pm
  • Editorial Team
    Editorial Team added an answer JQuery offers callbacks when the animation is complete. Then it… May 11, 2026 at 10:23 pm

Related Questions

I'm writing a program that needs to take input from an XBox 360 controller.
I am writing an application in C# that needs to run as a service
I have Virtual PC 2007. I am writing a C# program that will run
I'm writing (in C# with .NET 3.5) an administrative application which will poll multiple
I am developing a scientific application used to perform physical simulations. The algorithms used

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.