The Artima Developer Community
Sponsored Link

Java Answers Forum
Using java from command line

9 replies on 1 page. Most recent reply: Oct 13, 2006 1:12 PM by suba mahadevan

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 9 replies on 1 page
pepe bading

Posts: 4
Nickname: pepe85
Registered: Oct, 2005

Using java from command line Posted: Oct 6, 2005 6:50 AM
Reply to this message Reply
Advertisement
Hi,

I use java under Windows2000 to compile my applets.

I use the command line to do that and it displays the errors generated nicely.

But I wanted to build a java editor in vb or vc++, and I found a problem: Although It'S easy to make a system call with any of these two languages, I don't know how I can receive those errors in my application.

I tried the following but didn't work:
javac "c:\myfile.java" > "c:\output.txt"

Any Idea?
Thanks in advance.


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Using java from command line Posted: Oct 6, 2005 7:28 AM
Reply to this message Reply
It simply means your path is not configured.

pepe bading

Posts: 4
Nickname: pepe85
Registered: Oct, 2005

Re: Using java from command line Posted: Oct 6, 2005 7:42 AM
Reply to this message Reply
> It simply means your path is not configured.

Well, I think that you just did not understand my question.
Thanks anyway.

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Using java from command line Posted: Oct 6, 2005 8:23 AM
Reply to this message Reply
> > It simply means your path is not configured.
>
> Well, I think that you just did not understand my
> question.

I think I did. But lets go through the last bit of
your post:

javac "c:\myfile.java" > "c:\output.txt"

"javac" fires up the Java compiler, not so? It expects
the next String to either be an argment or an option,
not so? In any case what errors are you getting?
Would have probably helped forum members to respond
had you posted a subscript.

> Thanks anyway.

pepe bading

Posts: 4
Nickname: pepe85
Registered: Oct, 2005

Re: Using java from command line Posted: Oct 6, 2005 8:56 AM
Reply to this message Reply
> I think I did. But lets go through the last bit of

Well, I probably did not explain well.

I do not receive any error.

What I want to do is simply to find a way of building a java editor which is able to make a call to the javac command and receive a message from it.

This message may contain the errors which javac found when trying to compile the file, or simply an empty text if the compilation was successful.

Thanks again

Tapan kumar Rath

Posts: 18
Nickname: papuni
Registered: Sep, 2005

Re: Using java from command line Posted: Oct 6, 2005 8:54 PM
Reply to this message Reply
Why don't you use java to build the compiler.You can take the help of Process class that will get you all the output from any program.So write a class that will invoke javac.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Using java from command line Posted: Oct 7, 2005 9:32 PM
Reply to this message Reply
In whatever language you are using VB or C++, you'll need to look at the process creation APIs. When you create a process, you can get handles for both its standard out stream and its standard error stream. Reading these, while the compiling progresses allows you to show the messages in a different color (for exmples) than the errors.

What are you using to start the process? If you can do this in C# (or even managed C++ or VB.NET), you can use the .NET process API which makes this stuff very easy.

Bob Dobalina

Posts: 16
Nickname: hiredgoon
Registered: Apr, 2005

Re: Using java from command line Posted: Oct 9, 2005 8:56 AM
Reply to this message Reply
The output you see on a command line comes from 2 places, standard output and standard error. ">" by default redirects standard output, while your error messages are on standard error, which is why you weren't seeing them.

javac JavaSource.java > stdout.txt 2> stderr.txt

Now, to talk you out of writing your own IDE...

pepe bading

Posts: 4
Nickname: pepe85
Registered: Oct, 2005

Re: Using java from command line Posted: Oct 11, 2005 12:59 AM
Reply to this message Reply
Thank you very much, hiredgoon!

Fortunately, you have understood me,

Your solution is exactly what I was looking for (and it works!).

suba mahadevan

Posts: 2
Nickname: rawcoder
Registered: Oct, 2006

Re: Using java from command line-help needed Posted: Oct 13, 2006 1:12 PM
Reply to this message Reply
hi

i am developing a java editor too can u tell me how to save the errors in the java program to a file using VB.NET

Flat View: This topic has 9 replies on 1 page
Topic: i question about JDBC Previous Topic   Next Topic Topic: Emailing an Order in Java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use