Java and C#

G

geeshan_kumarasena

Hi,
I'm a IT student and doing a project to convert a C# source into a Java
Source.So I need to know how to Compile and Run C# and Java files
through my Java Program. and also I need to know how to read the system
registry to check weather the .NET is installed in the OS.Does anybody
have some codes to do these things. If so please let me know or please
tell me a way to do this. I search all over the web but couldn't found.
 
M

Mike Schilling

Hi,
I'm a IT student and doing a project to convert a C# source into a Java
Source.So I need to know how to Compile and Run C# and Java files
through my Java Program. and also I need to know how to read the system
registry to check weather the .NET is installed in the OS.Does anybody
have some codes to do these things. If so please let me know or please
tell me a way to do this. I search all over the web but couldn't found.

Compile C#: Start a process that runs CSC.
Run the C# program: start a process than runs the executable CSC produced.
Read the registry: Why? Assume CSC is in already the path, or have the user
use the -D flag to point to it.
 
G

geeshan_kumarasena

I need to read the system registry to enable a button of the GUI when
it starts.the button is enable only if the .NEt is installed in the
system. that's why I need to read the registry.
And I run CSC in command prompt.But it gives me this.
"'csc' is not recognized as an internal or external command,
operable program or batch file."
so what should I do.
How I get the exact path of the Csc compiler
 
M

Mike Schilling

I need to read the system registry to enable a button of the GUI when
it starts.the button is enable only if the .NEt is installed in the
system. that's why I need to read the registry.
And I run CSC in command prompt.But it gives me this.
"'csc' is not recognized as an internal or external command,
operable program or batch file."
so what should I do.
How I get the exact path of the Csc compiler

It's the same problem, really: if you can find the C# compiler, you can
enable your button. For .NET 1.1, it's in
<windir>\Microsoft.NET\Framework\v1.1.4322, where <windir> is the value of
the environment variable windir, usually c:\Windows or c:\WINNT . You can
write standard Java code to search for it on the disk; you'll need JNI to
read the registry.
 
G

geeshan_kumarasena

Thank you very much Mike Schilling. Your advises really worked. I got
through most of the inconviniences I had. and Thanks again.

with regards,
geeshan.
 
R

Roedy Green

I'm a IT student and doing a project to convert a C# source into a Java
Source.So I need to know how to Compile and Run C# and Java files
through my Java Program. and also I need to know how to read the system
registry to check weather the .NET is installed in the OS.Does anybody
have some codes to do these things. If so please let me know or please
tell me a way to do this. I search all over the web but couldn't found.
Somebody asked this same question recently. Was that you?

See these entries

http://mindprod.com/jgloss/exec.html -- how to spawn the C# compiler
http://mindprod.com/jgloss/javacexe.html -- how to compile from within
Java.

http://weather.com How to check the weather

How to detect if .net is installed File.exists. There must be some
file that acts as an indicator.
 
G

geeshan_kumarasena

Hi,
I got a new problem. I can pass the file and compile it. and also i can
run it through my java program. But if there is any error at compile
time how i can get it and display to the user. I have a message panel
in my GUI. So I need to compile the C# or Java File and get the
compiler output to the Message Panel. I tried so much. But I couldn't
find a way. does the compiler return something like resultSet object in
the database connections. Or how do I catch those outputs of the
compiler. If U know please let me know.

Geeshan
 
M

Mike Schilling

Hi,
I got a new problem. I can pass the file and compile it. and also i can
run it through my java program. But if there is any error at compile
time how i can get it and display to the user. I have a message panel
in my GUI. So I need to compile the C# or Java File and get the
compiler output to the Message Panel. I tried so much. But I couldn't
find a way. does the compiler return something like resultSet object in
the database connections. Or how do I catch those outputs of the
compiler. If U know please let me know.

Look at the Process object, in particular the methods on it that return
Streams.
 
G

geeshan_kumarasena

Hi,
Sorry for disturbing you.But I hoped after compiling with csc, it will
create the .exe for me. But it is not. it just compile the file. When I
checked I found that vsv$$$.bat file in the .NET directory does that
thing. It is the .NET command prompt. I couldn't pass the c# file to
it.It does not get any input files. So How do I create the .exe file.
Do you know any way to create the .exe. Please let me know. Now Iam
familier with passing parameters to the command prompt in my Java
program.

Thanks & regards

Geeshan
 
R

Ross Bamford

Hi,
Sorry for disturbing you.But I hoped after compiling with csc, it will
create the .exe for me. But it is not. it just compile the file. When I
checked I found that vsv$$$.bat file in the .NET directory does that
thing. It is the .NET command prompt. I couldn't pass the c# file to
it.It does not get any input files. So How do I create the .exe file.
Do you know any way to create the .exe. Please let me know. Now Iam
familier with passing parameters to the command prompt in my Java
program.

Thanks & regards

Geeshan

That's good. Now, please proceed to the relevant C# / .NET newsgroup.
This one is already above quota for non-Java threads.
 
R

Roedy Green

Sorry for disturbing you.But I hoped after compiling with csc, it will
create the .exe for me. But it is not. it just compile the file. When I
checked I found that vsv$$$.bat file in the .NET directory does that
thing. It is the .NET command prompt. I couldn't pass the c# file to
it.It does not get any input files. So How do I create the .exe file.
Do you know any way to create the .exe. Please let me know. Now Iam
familier with passing parameters to the command prompt in my Java
program.

I am not familiar with C#, but in C++, you must do a link step to
create an exe.
 
M

Mike Schilling

Roedy Green said:
I am not familiar with C#, but in C++, you must do a link step to
create an exe.

The C# compiler (cask) goes directly from source to executable, with no
intermediate steps (nothing like an object or class file).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top