G
Guest
ASP.NET 2.0 / Visual Studio 2005 / VB.Net 2.0
I have a web interface that needs to launch a java application.
What a long strange trip it has been...
I am using Process.Start process start info parameters, first to launch the
java app by itself with the call:
"C:\Program Files\Java\jdk1.5.0_12\bin\java.exe" javaAppName Arg1 Arg2
That didn't work so then I wrote a console app to call the java app, and I
call the console app from the web page by using Process.Start.
Now I get the following error reported from the console app:
java.lang.NoClassDefFoundError: javaAppName Exception in thread "main"
Please NOTE that when the console app is run through command prompt the java
app runs perfectly. I have checked and double checked permissions.
Console App code to launch java application:
Private Sub JavaJive()
My.Computer.FileSystem.CurrentDirectory = "C:\javaAppName\"
Try
Dim proc As Process = New Process()
Dim sjavaDir As String = "C:\Program Files\Java\jdk1.5.0_12\bin\"
Dim sjavaApp As String = "C:\javaAppName\"
Dim resourceDir As String = "C:\Inetpub\wwwroot\javaAppName\"
Dim pathArray() As String
pathArray = New String() {sjavaDir, sATradDir, resourceDir}
Dim fIOP As New FileIOPermission(PermissionState.Unrestricted)
fIOP.AddPathList(FileIOPermissionAccess.AllAccess, sjavaDir)
fIOP.AddPathList(FileIOPermissionAccess.AllAccess, sATradDir)
fIOP.AddPathList(FileIOPermissionAccess.AllAccess, resourceDir)
fIOP.SetPathList(FileIOPermissionAccess.AllAccess, pathArray)
With proc.StartInfo
.FileName = JAVAPath & CLASSPATH & " " & javaAppName & " " & _
ChrW(34) & Arg1 & ChrW(34) & " " & Arg2
.UseShellExecute = False
.RedirectStandardOutput = True
.RedirectStandardError = True
.WorkingDirectory = "C:\javaApp"
End With
proc.Start()
If proc.Responding Then proc.WaitForExit(120000) 'its a long
process...
Dim sReader As StreamReader = proc.StandardError
Console.WriteLine(String.Format("ProcErr: {0}{1}",
sReader.ReadToEnd, Environment.NewLine))
sReader = proc.StandardOutput
Console.WriteLine(String.Format("ProcOutPut: {0}{1}",
sReader.ReadToEnd, Environment.NewLine))
Catch ex As Exception
If Environment.UserInteractive Then
Console.WriteLine(String.Format("JavaCon {0}{1}Error: {2}", _
My.Application.Info.Version.ToString, _
Environment.NewLine, ex.Message))
End If
End Try
End Sub
Any suggestions greatly appreciated.
I have a web interface that needs to launch a java application.
What a long strange trip it has been...
I am using Process.Start process start info parameters, first to launch the
java app by itself with the call:
"C:\Program Files\Java\jdk1.5.0_12\bin\java.exe" javaAppName Arg1 Arg2
That didn't work so then I wrote a console app to call the java app, and I
call the console app from the web page by using Process.Start.
Now I get the following error reported from the console app:
java.lang.NoClassDefFoundError: javaAppName Exception in thread "main"
Please NOTE that when the console app is run through command prompt the java
app runs perfectly. I have checked and double checked permissions.
Console App code to launch java application:
Private Sub JavaJive()
My.Computer.FileSystem.CurrentDirectory = "C:\javaAppName\"
Try
Dim proc As Process = New Process()
Dim sjavaDir As String = "C:\Program Files\Java\jdk1.5.0_12\bin\"
Dim sjavaApp As String = "C:\javaAppName\"
Dim resourceDir As String = "C:\Inetpub\wwwroot\javaAppName\"
Dim pathArray() As String
pathArray = New String() {sjavaDir, sATradDir, resourceDir}
Dim fIOP As New FileIOPermission(PermissionState.Unrestricted)
fIOP.AddPathList(FileIOPermissionAccess.AllAccess, sjavaDir)
fIOP.AddPathList(FileIOPermissionAccess.AllAccess, sATradDir)
fIOP.AddPathList(FileIOPermissionAccess.AllAccess, resourceDir)
fIOP.SetPathList(FileIOPermissionAccess.AllAccess, pathArray)
With proc.StartInfo
.FileName = JAVAPath & CLASSPATH & " " & javaAppName & " " & _
ChrW(34) & Arg1 & ChrW(34) & " " & Arg2
.UseShellExecute = False
.RedirectStandardOutput = True
.RedirectStandardError = True
.WorkingDirectory = "C:\javaApp"
End With
proc.Start()
If proc.Responding Then proc.WaitForExit(120000) 'its a long
process...
Dim sReader As StreamReader = proc.StandardError
Console.WriteLine(String.Format("ProcErr: {0}{1}",
sReader.ReadToEnd, Environment.NewLine))
sReader = proc.StandardOutput
Console.WriteLine(String.Format("ProcOutPut: {0}{1}",
sReader.ReadToEnd, Environment.NewLine))
Catch ex As Exception
If Environment.UserInteractive Then
Console.WriteLine(String.Format("JavaCon {0}{1}Error: {2}", _
My.Application.Info.Version.ToString, _
Environment.NewLine, ex.Message))
End If
End Try
End Sub
Any suggestions greatly appreciated.