Starting bbcomm in Java v3 Bloomberg API

前端 未结 4 1930
鱼传尺愫
鱼传尺愫 2021-01-05 12:57

When I use the Java Bloomber V3 API it usually works. However, sometimes, especially after a reboot, bbcomm.exe is not running in the background. I can start it manually by

4条回答
  •  天命终不由人
    2021-01-05 13:16

    I know this is an old post but I figured I would add my solution for a reference in case someone needs help checking/starting bbcomm.exe process from the code hiding console window.

    This snippet is written in C# but I hope you can easily translate it to Java.

    void Main()
    {
        var processes = Process.GetProcessesByName("bbcomm");
        if (processes.Any())
        {
            Console.WriteLine(processes.First().ProcessName + " already running");
            return;
        }
    
        var exePath = @"C:\blp\DAPI\bbcomm.exe";
        var processStart = new ProcessStartInfo(exePath);
        processStart.UseShellExecute = false;
        processStart.CreateNoWindow = true;
        processStart.RedirectStandardError = true;
        processStart.RedirectStandardOutput = true;
        processStart.RedirectStandardInput = true;  
        var process = Process.Start(processStart);
        Console.WriteLine(process.ProcessName + " started");
    }
    

提交回复
热议问题