Hi overthere,
I'm trying to compile some Java code within a C# application form. So the
end user will write his/her code in a textbox and a button compile will
compiles it.
I tried to use System.Diagnost ics.Process.Sta rt() but the console
application was launched too.
I want to compile and retrieve the errors/messages without lauching another
app and showing the errors/messages in within my winform.
Any tip will be very much appreciated.
Thank You in advance. 5 2069
Ali,
It seems that it is working in the background but I'm not able to read out
the messages. Am I doing something wrong ????
ProcessStartInf o p = new ProcessStartInf o("C:\\javac.ex e",
"C:\\Hello.java ");
p.RedirectStand ardOutput=true;
p.RedirectStand ardError=true;
p.UseShellExecu te=false;
p.CreateNoWindo w=true;
Process ps = Process.Start(p );
this.label1.Tex t=ps.StandardOu tput.ReadLine() ; //reads nothing...??
When I run it from the console I get these error messages:
C:\javac.exe Hello.java
Hello.java:3: invalid method declaration;
return type required
public sayHello()
^
Hello.java:5: write(java.lang .String) has
private access in java.io.PrintSt ream
System.out.writ e("hello");
^
2 errors
Thanks a lot !!!!
"Ali" <aa*******@gmai l.com> wrote in message
news:86******** *************** ***********@mic rosoft.com... When calling the System.Diagnost ics.Process.Sta rt() method, pass it an
object of type ProcessStartInf o with the following properties set:
ProcessStartInf o p=new ProcessStartInf o("ConsoleAppli cation1.exe"); p.RedirectStand ardOutput=true; p.RedirectStand ardError=true; p.UseShellExecu te=false; p.CreateNoWindo w=true; Process ps = Process.Start(p ); this.label1.Tex t=ps.StandardOu tput.ReadLine() ;
now when the procss starts, it doesnot have a window (so no console
window) and all the output to the standard output and standard error stream are redirected to the ps.StandardOutp ut stream and can be read using any of
the stream access mechenisms (such as ReadLine being used in the above
sample). Hope this helps
Ali Gardezi
genc ymeri <ge********@hot mail.com> wrote: It seems that it is working in the background but I'm not able to read out the messages. Am I doing something wrong ????
ProcessStartInf o p = new ProcessStartInf o("C:\\javac.ex e", "C:\\Hello.java "); p.RedirectStand ardOutput=true; p.RedirectStand ardError=true; p.UseShellExecu te=false; p.CreateNoWindo w=true; Process ps = Process.Start(p ); this.label1.Tex t=ps.StandardOu tput.ReadLine() ; //reads nothing...??
Have you tried reading from StandardError instead of StandardOutput?
After all, those are error messages.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Yeap, it works reading standart errors.
Thanks a lot Ali & Jon :) :)
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com... genc ymeri <ge********@hot mail.com> wrote: It seems that it is working in the background but I'm not able to read
out the messages. Am I doing something wrong ????
ProcessStartInf o p = new ProcessStartInf o("C:\\javac.ex e", "C:\\Hello.java "); p.RedirectStand ardOutput=true; p.RedirectStand ardError=true; p.UseShellExecu te=false; p.CreateNoWindo w=true; Process ps = Process.Start(p ); this.label1.Tex t=ps.StandardOu tput.ReadLine() ; //reads nothing...??
Have you tried reading from StandardError instead of StandardOutput? After all, those are error messages.
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Error messages are sent to standard error, thats why i have also redirected
standard error in the given code. So instead of doing
ps.StandardOutp ut.ReadLine(); to read error messages, use
ps.StandardErro r.ReadLine(); to see if the compiler returned error messages.
Ali Gardezi
"genc ymeri" wrote: Ali, It seems that it is working in the background but I'm not able to read out the messages. Am I doing something wrong ????
ProcessStartInf o p = new ProcessStartInf o("C:\\javac.ex e", "C:\\Hello.java "); p.RedirectStand ardOutput=true; p.RedirectStand ardError=true; p.UseShellExecu te=false; p.CreateNoWindo w=true; Process ps = Process.Start(p ); this.label1.Tex t=ps.StandardOu tput.ReadLine() ; //reads nothing...??
When I run it from the console I get these error messages:
C:\javac.exe Hello.java
Hello.java:3: invalid method declaration; return type required public sayHello() ^ Hello.java:5: write(java.lang .String) has private access in java.io.PrintSt ream System.out.writ e("hello"); ^ 2 errors
Thanks a lot !!!! "Ali" <aa*******@gmai l.com> wrote in message news:86******** *************** ***********@mic rosoft.com... When calling the System.Diagnost ics.Process.Sta rt() method, pass it an object of type ProcessStartInf o with the following properties set:
ProcessStartInf o p=new ProcessStartInf o("ConsoleAppli cation1.exe"); p.RedirectStand ardOutput=true; p.RedirectStand ardError=true; p.UseShellExecu te=false; p.CreateNoWindo w=true; Process ps = Process.Start(p ); this.label1.Tex t=ps.StandardOu tput.ReadLine() ;
now when the procss starts, it doesnot have a window (so no console window) and all the output to the standard output and standard error stream are redirected to the ps.StandardOutp ut stream and can be read using any of the stream access mechenisms (such as ReadLine being used in the above sample). Hope this helps
Ali Gardezi
thanks a lot :) :)
"Ali" <aa*******@gmai l.com> wrote in message
news:E4******** *************** ***********@mic rosoft.com... Error messages are sent to standard error, thats why i have also
redirected standard error in the given code. So instead of doing ps.StandardOutp ut.ReadLine(); to read error messages, use ps.StandardErro r.ReadLine(); to see if the compiler returned error
messages. Ali Gardezi
"genc ymeri" wrote:
Ali, It seems that it is working in the background but I'm not able to read
out the messages. Am I doing something wrong ????
ProcessStartInf o p = new ProcessStartInf o("C:\\javac.ex e", "C:\\Hello.java "); p.RedirectStand ardOutput=true; p.RedirectStand ardError=true; p.UseShellExecu te=false; p.CreateNoWindo w=true; Process ps = Process.Start(p ); this.label1.Tex t=ps.StandardOu tput.ReadLine() ; //reads nothing...??
When I run it from the console I get these error messages:
C:\javac.exe Hello.java
Hello.java:3: invalid method declaration; return type required public sayHello() ^ Hello.java:5: write(java.lang .String) has private access in java.io.PrintSt ream System.out.writ e("hello"); ^ 2 errors
Thanks a lot !!!! "Ali" <aa*******@gmai l.com> wrote in message news:86******** *************** ***********@mic rosoft.com... When calling the System.Diagnost ics.Process.Sta rt() method, pass it an object of type ProcessStartInf o with the following properties set:
ProcessStartInf o p=new ProcessStartInf o("ConsoleAppli cation1.exe"); p.RedirectStand ardOutput=true; p.RedirectStand ardError=true; p.UseShellExecu te=false; p.CreateNoWindo w=true; Process ps = Process.Start(p ); this.label1.Tex t=ps.StandardOu tput.ReadLine() ;
now when the procss starts, it doesnot have a window (so no console window) and all the output to the standard output and standard error stream
are redirected to the ps.StandardOutp ut stream and can be read using any
of the stream access mechenisms (such as ReadLine being used in the above sample). Hope this helps
Ali Gardezi
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Brian |
last post by:
I am having alot of trouble getting a XML document validated with a
schema.
I got a sample document and schema off of w3schools.com, which passed
an online xml validator:
http://tools.decisionsoft.com/schemaValidate.html. I cannot, however,
get them validated programmatically.
The documents are:
|
by: Raphael A. Bauer |
last post by:
Hi,
I am just using this Java code:
----------
//Read it => automatically converts it to UTF-8
DocumentBuilderFactory factory = DocumentBuilderFactory
.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(new File(fileName));
|
by: DrUg13 |
last post by:
In java, this seems so easy. You need a new object
Object test = new Object() gives me exactly what I want.
could someone please help me understand the different ways to do the
same thing in C++. I find my self sometimes, trying
Object app = Object();
Object *app = Object();
Object app = new Object();
|
by: Rhino |
last post by:
I've spent the last couple of hours trying to figure out how to debug a Java
stored procedure and am just going in circles. The last straw came when I
got "Cannot open input stream for default" when I launched the IBM
Distributed Debugger via
D:\IBMDebug>idebug.exe -qdaemon -quiport=8000,8001
First, a bit of background.
I am running DB2 V7.2 with Fixpack 9 applied on Windows XP Professional (all
critical service applied). I've written...
|
by: Michael |
last post by:
Running DB2 v7 UDB ("DB2 v7.1.0.93", "n031208" and "WR21333") on Windows XP,
I am unable to find out why the "Build for Debug" option within Stored
Procedure Builder is not enabled on Java stored procedures. It is enabled
for SQL stored procedures.
It is possible to "Build" and "Run" the Java SPs, it just isn't possible to
click on the "Build for Debug" option. Thanks for any help in advance.
Michael
| |
by: surabhi |
last post by:
A while ago I evaluated Eclipse vs Visual Studio, and settled on
Visual Studio 2005. Eclipse is better in many ways, but the lack of
a gui builder was the deciding factor. Visual Studio 2005 has an
excellent gui builder. Eclipse doesn't, and in fact, none of the
Java IDEs had a half-decent gui builder. Our apps will have lots of
dialogs, and we didn't waste our careers hand-coding GridBagLayouts.
But the new NetBeans Java IDE has the...
|
by: maya |
last post by:
hi,
I'm following example 'Intro7.aspx' here,
http://www.csharpfriends.com/quickstart/aspplus/doc/webformsintro.aspx#customctrls
it says on top of Acme.cs "namespace Acme" I assume this means Acme.cs
has to be in a dir called 'Acme'? (am assuming namespace is equiv to
Java's packages; is this right?)
at any rate I can't compile Acme.cs.. get errors (I'm compiling in
|
by: KyleUbenk |
last post by:
Hello, I am attempting to compile java code from within my program. Basically I have a file in the directory with Java source code, and I want to be able to compile it from within my program. The only solution I have found so far is running the javac process :
Process.Start("javac source.java); But this doesn't seem to work (File not found).
And i would also like to get the output after compiling to a string (Error messages etc). Any other...
|
by: hussainsaiger |
last post by:
I am trying to convert a python module (that contains the use of
NLTK.Corpus) by jythonc. It is not able to include nltk dependencies
within the java class it creates. So when i use this class in java, it
fails to recognize nltk. Can anyone please let me know how should i
use nltk in python/jython modules so i can use in Java.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |