Thread: How to run a Jar file and another C++ program with a C++ program

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    38

    Question How to run a Jar file and another C++ program with a C++ program

    I sort of made a messed up program where half of it is in java and the other half is in C++.

    So i plan to make a third program that would run the Jar file first then after that would run the C++ program.

    Anyone know how and where i would start? I tired googling it but, my Jar isn't a application, i can only run it via command prompt which i'm not sure how to do in C++.

    edit:I created a batch file to run the Jar. Currently trying to make a program that runs a batch file.
    Last edited by airesore; 10-12-2011 at 10:57 AM.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    what platform are you running on? linux, windows, mac, etc

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    38
    windows

    Edit:I figured it out, thanks anyways
    Edit2: how do i get a value from another program? I know how to make a txt file to transfer data if it use of/ifstreams, but i would like to know a easier way.
    Last edited by airesore; 10-12-2011 at 12:43 PM.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Shared memory. However, you have to realize that if it's going to work or not depends on what programming languages you intend to use it in. Sharing data between a Java program and a C++ program is going to be difficult.

    Maybe I should just ask what you are intending to accomplish?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Sep 2011
    Posts
    38
    Just need to get the user input which is a simple one line string from the java application to the C++ application like filename and save location.

    Java application reads a xml file and creates a sorted CSV, C++ application take this CSV file and split them up in to business groups on different CSV files.

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    you can do all that in C++. check out tinyxml and tinyxpath.

    from there, creating csv files is trivial.

  7. #7
    Just a pushpin. bernt's Avatar
    Join Date
    May 2009
    Posts
    426
    I know how to make a txt file to transfer data if it use of/ifstreams, but i would like to know a easier way.
    You can avoid a temporary .txt file by using your batch file to "pipe" the output of the first program to the second program.
    Consider this post signed

  8. #8
    Registered User
    Join Date
    Sep 2011
    Posts
    38
    @Elkvis All the main funcation of the program is done. I don't really want to spend a few more days playing with XML.

    @bernt hmm...so if i run a program with piping in C++, then the first input would be the one that i pipe through? eg. My GUI C++ program get a user input then calls a jar. Would my input go to the jar when it ask for user input or would there need to be a recieving function?

    Alternatively I think clipboarding it would be an easy way too. However I would like try experiment with piping since it does seem pretty interesting.

  9. #9
    Just a pushpin. bernt's Avatar
    Join Date
    May 2009
    Posts
    426
    @bernt hmm...so if i run a program with piping in C++, then the first input would be the one that i pipe through? eg. My GUI C++ program get a user input then calls a jar. Would my input go to the jar when it ask for user input or would there need to be a recieving function?
    Piping takes standard output (so in C++, the cout stream) from the first program and sends it to the second program's standard input (Java's System.in). Or when used with file paths, it will read from/write to the file depending on whether the file comes before or after the '|' symbol.
    Consider this post signed

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic file read, file write program
    By starwarsyeah in forum C++ Programming
    Replies: 5
    Last Post: 02-28-2011, 03:23 PM
  2. program that reads text from a file and encodes the file by.....
    By kendrakay2000 in forum C++ Programming
    Replies: 5
    Last Post: 12-05-2010, 06:06 PM
  3. Replies: 2
    Last Post: 03-04-2010, 04:19 AM
  4. Replies: 1
    Last Post: 03-03-2009, 04:47 PM
  5. Replies: 18
    Last Post: 11-13-2006, 01:11 PM

Tags for this Thread