469,599 Members | 2,644 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,599 developers. It's quick & easy.

calling java class from web page

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.

--
Coding in Sunny Central Florida
Jul 9 '07 #1
6 4747

I would suggest converting the Java app to .NET.

http://www.ikvm.net/

HTH,

Sam

------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.

On Mon, 9 Jul 2007 06:16:02 -0700, VB Jonnie
<VB******@discussions.microsoft.comwrote:
>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
Jul 9 '07 #2
Thanks for the information, Sam. I will look into IKVM, at first glance it
looks promising, but probably for future projects. This particular project
involves using java code to interact with Pro/E (3D CAD application), and due
to project time constraints re-writing the entire app would be too costly.
--
Coding in Sunny Central Florida
"Samuel R. Neff" wrote:
>
I would suggest converting the Java app to .NET.

http://www.ikvm.net/

HTH,

Sam

------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.

On Mon, 9 Jul 2007 06:16:02 -0700, VB Jonnie
<VB******@discussions.microsoft.comwrote:
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

Jul 9 '07 #3
Have you check that the CLASSPATH environment variable is available ? You
could likely also add the -classpath option in the command line.

You could also try a Java group as this is IMO rleated to a Java
configuration (the classpath environment variable) rather than a problem
with .NET.

---
Patrice


"VB Jonnie" <VB******@discussions.microsoft.coma écrit dans le message de
news: 41**********************************@microsoft.com...
Thanks for the information, Sam. I will look into IKVM, at first glance it
looks promising, but probably for future projects. This particular project
involves using java code to interact with Pro/E (3D CAD application), and
due
to project time constraints re-writing the entire app would be too costly.
--
Coding in Sunny Central Florida
"Samuel R. Neff" wrote:
>>
I would suggest converting the Java app to .NET.

http://www.ikvm.net/

HTH,

Sam

------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.

On Mon, 9 Jul 2007 06:16:02 -0700, VB Jonnie
<VB******@discussions.microsoft.comwrote:
>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


Jul 9 '07 #4
Patrice,

I have tried adding the -classpath to the command line call but it did not
help, unfortunately.

When I run either a batch file or .net console app from the command line the
java application launches correctly and runs the Pro/E program as desired. It
is only when I attempt to call either of these apps (batch file or console
app) from my ASP.Net page that the java application does not launch.

Thanks for the input, I am still looking into permissions and perhaps IIS
restrictions to accessing external files. My hope is that someone reading
this discussion will have come accross this type of issue before.

I have sucessfully used Process.Start through an ASP.Net web page to start
up an external application.
--
Coding in Sunny Central Florida
"Patrice" wrote:
Have you check that the CLASSPATH environment variable is available ? You
could likely also add the -classpath option in the command line.

You could also try a Java group as this is IMO rleated to a Java
configuration (the classpath environment variable) rather than a problem
with .NET.

---
Patrice


"VB Jonnie" <VB******@discussions.microsoft.coma écrit dans le message de
news: 41**********************************@microsoft.com...
Thanks for the information, Sam. I will look into IKVM, at first glance it
looks promising, but probably for future projects. This particular project
involves using java code to interact with Pro/E (3D CAD application), and
due
to project time constraints re-writing the entire app would be too costly.
--
Coding in Sunny Central Florida
"Samuel R. Neff" wrote:
>
I would suggest converting the Java app to .NET.

http://www.ikvm.net/

HTH,

Sam

------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.

On Mon, 9 Jul 2007 06:16:02 -0700, VB Jonnie
<VB******@discussions.microsoft.comwrote:

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



Jul 9 '07 #5
The error message really make me think that some class is not found. Double
check perhaps that you don't depend on a class whose definition is not in
the classpath. (are you using the same value than the one found in the
environment variable, use SET to majke sure the environment variable hold
the same value than the one you tried).

Tools from sysinternals (redirects to MS) such as the "filemon" tool could
also help as you could see which classes are loaded when using the command
line and whihc file it doesn't find when running from an ASP.NET page (or if
perhaps the directory in whihc are Java classes doesn't have the appropriate
ACL).

---
Patrice

"VB Jonnie" <VB******@discussions.microsoft.coma écrit dans le message de
news: 1E**********************************@microsoft.com...
Patrice,

I have tried adding the -classpath to the command line call but it did not
help, unfortunately.

When I run either a batch file or .net console app from the command line
the
java application launches correctly and runs the Pro/E program as desired.
It
is only when I attempt to call either of these apps (batch file or console
app) from my ASP.Net page that the java application does not launch.

Thanks for the input, I am still looking into permissions and perhaps IIS
restrictions to accessing external files. My hope is that someone reading
this discussion will have come accross this type of issue before.

I have sucessfully used Process.Start through an ASP.Net web page to start
up an external application.
--
Coding in Sunny Central Florida
"Patrice" wrote:
>Have you check that the CLASSPATH environment variable is available ? You
could likely also add the -classpath option in the command line.

You could also try a Java group as this is IMO rleated to a Java
configuration (the classpath environment variable) rather than a problem
with .NET.

---
Patrice


"VB Jonnie" <VB******@discussions.microsoft.coma écrit dans le message
de
news: 41**********************************@microsoft.com...
Thanks for the information, Sam. I will look into IKVM, at first glance
it
looks promising, but probably for future projects. This particular
project
involves using java code to interact with Pro/E (3D CAD application),
and
due
to project time constraints re-writing the entire app would be too
costly.
--
Coding in Sunny Central Florida
"Samuel R. Neff" wrote:
I would suggest converting the Java app to .NET.

http://www.ikvm.net/

HTH,

Sam

------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.

On Mon, 9 Jul 2007 06:16:02 -0700, VB Jonnie
<VB******@discussions.microsoft.comwrote:

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




Jul 9 '07 #6
Patrice,

The tools from sysinternals are awesome, thanks for the heads up. I was able
to identify a couple of access denial errors and correct them using the
process monitor.

I posted a reply to Roland Dick with details of my adventures, and have
checked and double checked classpath variables and used the -classpath switch.

Thanks for the assistance.
--
Coding in Sunny Central Florida
"Patrice" wrote:
The error message really make me think that some class is not found. Double
check perhaps that you don't depend on a class whose definition is not in
the classpath. (are you using the same value than the one found in the
environment variable, use SET to majke sure the environment variable hold
the same value than the one you tried).

Tools from sysinternals (redirects to MS) such as the "filemon" tool could
also help as you could see which classes are loaded when using the command
line and whihc file it doesn't find when running from an ASP.NET page (or if
perhaps the directory in whihc are Java classes doesn't have the appropriate
ACL).

---
Patrice
Jul 11 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Klaus Friese | last post: by
5 posts views Thread by Nick Flandry | last post: by
7 posts views Thread by Christian Wilhelm | last post: by
4 posts views Thread by simon | last post: by
4 posts views Thread by raghuvendra | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.