running an external program, using the saved file as input for my java program?
Author |
Message |
jason_lee_91
|
Posted: Sun Jan 16, 2011 8:06 pm Post subject: running an external program, using the saved file as input for my java program? |
|
|
hi guys
im trying to write a java program that runs an external program
i tried to search on the internet for this but i had a hard time finding what i needed
maybe it is a very specific or weird question?
but i was hoping you guys could help me out
my current java program takes a text file and edits it and saves it as a text file.
what i want to do is use my Optical Character Recognition software that is installed on my computer (Mac OS), to take a scanned document, convert it in to a text file and use that text file as input for my java code
so that means i dont even care if the text file taht the OCT software creates is saved as long as my java program is able to use it before the file is deleted.
additional info:
the OCR software i am using is ABBYY filereader
its a fairly simple software interms of execution.
you turn the software on, upload an image, and press convert to ____ (whatever option u want)
it then tells u to choose a save directory
so more specifically, is there a way i can get my java program to run ABBYY, upload the specified file, convert to the specified type, then use that saved file as an input for my java program?
heres what i ahve so far:
import java.io.*;
public class Main {
public static void main(String argv[]) {
try {
String line;
Process p = Runtime.getRuntime().exec(new String[]{"open","-a","ABBYY","/test.pdf"});
BufferedReader input = new BufferedReader (new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null)
{
System.out.println(line);
}
input.close();
}
catch (Exception err) {err.printStackTrace();
}
}
}
so in other words how do i get my program to actually conver the test.pdf file, save it and set the BufferedReader "input" as the new test file?
i am fairly new to computer programmnig so i might be asking a bad question
but any insight would be much appreciated! |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Sun Jan 16, 2011 8:37 pm Post subject: RE:running an external program, using the saved file as input for my java program? |
|
|
if ABBYY can be completely controlled through the Terminal.app, then you can issue such commands.
Otherwise you might have better luck with something like Automator -- http://www.macosxautomation.com/automator/ |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
jason_lee_91
|
Posted: Sun Jan 16, 2011 8:41 pm Post subject: RE:running an external program, using the saved file as input for my java program? |
|
|
yes i thought maybe i can use terminal
the only problem is i can get to the point in terminal where i upload the file on to ABBYY but i still have to actually press "convert to text" with my mouse the press "save" with my mouse
how do i find out with ABBYY, or any other program at that matter can be completely controlled through the terminal app?
i also do ahve access to a windows computer.
would that help? |
|
|
|
|
|
Tony
|
Posted: Sun Jan 16, 2011 9:01 pm Post subject: Re: RE:running an external program, using the saved file as input for my java program? |
|
|
jason_lee_91 @ Sun Jan 16, 2011 8:41 pm wrote: how do i find out with ABBYY, or any other program at that matter can be completely controlled through the terminal app?
Program's documentation.
jason_lee_91 @ Sun Jan 16, 2011 8:41 pm wrote:
i also do ahve access to a windows computer.
would that help?
Unlikely. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
jason_lee_91
|
Posted: Sun Jan 16, 2011 9:06 pm Post subject: RE:running an external program, using the saved file as input for my java program? |
|
|
so the programs documentation
i tried looknig for it in the package contents of the application but i am having a ahrd time deciding which one it is
in general how can i find this documentation? |
|
|
|
|
|
jason_lee_91
|
Posted: Sun Jan 16, 2011 9:16 pm Post subject: RE:running an external program, using the saved file as input for my java program? |
|
|
i also looked into automator a bunch and it feels like i can only use built in mac applications as actions
is there a way around that?
also how do i run a java program?
do i save it as a jar? |
|
|
|
|
|
Tony
|
Posted: Sun Jan 16, 2011 9:28 pm Post subject: RE:running an external program, using the saved file as input for my java program? |
|
|
I thought Automator allowed one to record actions, and run bash scripts? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
jason_lee_91
|
Posted: Sun Jan 16, 2011 9:42 pm Post subject: RE:running an external program, using the saved file as input for my java program? |
|
|
it does but i think it works by mouse clicks and location which i find to be very sketchy
i also found that automator is able to use applescript which may be of help
but i do wish to try and make this cross-platform
is there by anychance a built in OCR class in java?
long shot i know haha but it would be real nice |
|
|
|
|
|
Sponsor Sponsor
|
|
|
btiffin
|
Posted: Sun Jan 16, 2011 9:51 pm Post subject: RE:running an external program, using the saved file as input for my java program? |
|
|
I may be speaking out of turn, but will
http://download.oracle.com/javase/6/docs/api/java/awt/Robot.html
help with this sort of problem?
Class java.awt.Robot facilitates generating native system keyboard and mouse events.
Cheers |
|
|
|
|
|
jason_lee_91
|
Posted: Mon Jan 17, 2011 12:46 am Post subject: RE:running an external program, using the saved file as input for my java program? |
|
|
i suppose this could some what work but i would rather not use this because changing the comptuer would make the program not work
i would rather have the program look for the file in the computer so i can just change the directory name for new files |
|
|
|
|
|
|
|