Home : J-Integra for .NET : How to start the J-Integra Server programmatically and silently
Q147178 - HOWTO: How to start the J-Integra Server programmatically and silently

How to start the J-Integra Server programmatically and silently

 

When accessing Java Server from .NET clients, you may want to start the J-Integra server programmatically and silently. That means no console window showing, J-Integra Server is invisible to users.

To start the J-Integra Server silently, you have to write a custom wrapper class to call com.intrinsyc.janet.control.Janet.init() and use command javaw instead of java to start the J-Integra Server.

An extremely simple custom wrapper class is provided below:

import com.intrinsyc.janet.control.*;
import java.io.IOException;

public class Main {
  private Main() {}
  public static void main(String[] args) throws com.intrinsyc.janet.RemoteException {
    Janet.init();
  }
}

To start the J-Integra Server using above wrapper class:
javaw -cp $USER_INSTALL_DIR$\lib\janet.jar;. Main

However, if you use this way to start J-Integra Server, you have to manully kill its process from Windows Task Manager.

To start J-Integra Server programmatically, you can write a VB/C# program to start it at a process. The following is an example for this feature implemented in VB.NET.
Imports System
Imports System.Diagnostics
Imports System.ComponentModel

Namespace MyProcessSample
 Public Class MyProcess
  Private ERROR_FILE_NOT_FOUND As Integer = 2
  Private ERROR_ACCESS_DENIED As Integer = 5
  Private Sub runRegSvr32()

    Dim myProcess As New Process
    Try
      myProcess.StartInfo.FileName = "javaw.exe"
      myProcess.StartInfo.Arguments = " -cp ""C:\Program Files\J-Integra\.NET\lib\janet.jar"";. Main"
      myProcess.StartInfo.CreateNoWindow = True
      myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
      myProcess.StartInfo.UseShellExecute = False
      myProcess.StartInfo.RedirectStandardOutput = True
      myProcess.Start()
      'myProcess.WaitForExit()
      'myProcess.Dispose()
    Catch e As Win32Exception
      If e.NativeErrorCode = ERROR_FILE_NOT_FOUND Then
        Console.WriteLine((e.Message + ". Check the path."))
      Else
        If e.NativeErrorCode = ERROR_ACCESS_DENIED Then
            Console.WriteLine((e.Message + ". You do not have permission to run this."))
        End If
      End If
    End Try
  End Sub

  Public Shared Sub Main()
    Dim myProcess As New MyProcess
    myProcess.runRegSvr32()
  End Sub
 End Class
End Namespace


You can use above methods to start J-Integra Server programmatically and silently. You can also use the same way to distribute the server together with your program.
Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.
Created on 6/23/2006.
Last Modified on 7/10/2006.
Last Modified by No Author Name Available!.
Article has been viewed 10785 times.
Rated 4 out of 10 based on 2 votes.
Print Article
Email Article