473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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 4917

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: headph0nes | last post by:
Hi there, I'd like to know whether it's possible to call Java classes compiled with the latest Sun JDK from an ASP page? All the documentation I've been able to find on the net has referred to...
3
by: Rajesh | last post by:
Hi, I am using iplanet webserver 4.1. I want to call a java class from ssjs file. But I am not getting the result. I have created a java class file and put it in the folder...
7
by: Klaus Friese | last post by:
Hi, i'm currently working on a plugin for Adobe InDesign and i have some problems with that. I'm not really a c++ guru, maybe somebody here has an idea how to solve this. The plugin is...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
7
by: Christian Wilhelm | last post by:
Hi! I'm trying to call a Java WebService out of a .net Client. There are two Methods, one Method requires one Parameter of type Parameter, the other Method requires one Parameter of type...
4
by: simon | last post by:
hello, may have a need shortly to call a java class from a vb.net web app. basically the java class would serve as an email creation/sending function. i realize this all could be done in .net,...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
4
by: raghuvendra | last post by:
Hi I have a jsp page with 4 columns: namely Category name , Category order, Input field and a submit button. All these are aligned in a row. And Each Category Name has its corresponding Category...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.