Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-06-2007, 11:41 AM
Member
 
Join Date: Nov 2007
Posts: 1
Amit Kr. Mishra is on a distinguished road
Poblem in Compiling a c++ file from a java program...
// This is the program to Compile a c++ file from a java program, & get compiler generated files in the file's parent directory.

//problem is that though it neither generate err nor throws exception, yet doesn't compile, PLEASE HELP. or suggest any other solution

Code:
import java.io.*; class CompileCppFile{ File file; CompileCppFile(File file){ this.file = file; } public void compile(){ try{ String[] cmd = new String[4]; cmd[0] = "cmd.exe"; cmd[1] = "/C"; cmd[2] = "PATH = C:\\TC\\BIN"; //where C++ is installed. cmd[3] = "TCC " + file.getName(); //not working. but why? http://www.java-forums.org/images/smilies/confused.gif :confused: Process p= Runtime.getRuntime().exec( cmd, null, new File( file.getParent()) ); /* String[] envp = new String[1]; envp[0] = "PATH = C:\\TC\\BIN"; Process p= Runtime.getRuntime().exec( cmd, envp, new File( file.getParent()) ); //has no effect */ BufferedReader err = new BufferedReader( new InputStreamReader(p.getErrorStream()) ); String line; while( (line = err.readLine()) != null) System.out.println(line); BufferedReader output = new BufferedReader( new InputStreamReader(p.getInputStream()) ); while( (line = output.readLine()) != null) System.out.println(line); } catch(Exception ioE){ System.out.println(ioE.getMessage()); ioE.printStackTrace(); } } } class CompileCpp{ public static void main(String args[]){ CompileCppFile c = new CompileCppFile(new File("F:/Amit/WorkHouse/Test.cpp")); c.compile(); } }

Last edited by JavaBean : 11-06-2007 at 11:49 AM. Reason: Code placed inside [code] block
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get the last modified date of a file from a java program Java Tip java.io 0 04-04-2008 03:45 PM
How to execute an External Program through Java program Java Tip java.io 0 04-04-2008 03:40 PM
How to execute an External Program through Java program JavaBean Java Tips 0 10-04-2007 10:33 PM
getting problem in compiling java program? sathish04021984 New To Java 3 07-30-2007 10:26 AM
writing to a excel file from java program priyankabhar New To Java 1 07-10-2007 09:05 PM


All times are GMT +3. The time now is 10:20 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org