Our java program is suppose to call a program created by our vendor in C#. We are given two files
1.An exe file
2.An xml file...which its contents go something like this
<doc>
<assembly><name>someProgram</name></assembly>
<members>
<member name="P:SomeConnector.callSomeOtherProgram()">
<summary>a method to connect to some program</summary>
<remarks></remarks>
</member>
</members>
</doc>
We're clueless on how to so this. Anyone got ideas?
for running comman line in java use:
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("MyOtherProg.exe progParameter1 progParameter2");
judging by your comment and question i think you have a class library, and the right way to approach this would be to just create your own C# program that calls the different method on that class library using the given xml as a program args or other way
Edit
your comment:
unning the exe manually (double click) shows up a wizard with an input
text field and some buttons which does different tasks. the idea is
for our java program to automatically run it and provide the fields
and execute which buttons we would like to trigger to do the function
we want. the java program just automates whatever is done manually
answer:
ok, now we're coking with fire :)
so, at this point i would go to the vendor and ask if i can get a class library instead of the current ui, as you want it running automatically, without Human intervention. while on it i would check if you got other .dll files with the program. if so investigate them using VS.
one last thing, if all is turn bad and you have to do clicks, it's not lost yet, but at this point you have a lot of work, and i can't help you from here, but i'll send you to a link to start what you need and you'll explore from there:
clicking robot
youtube video on the subject
Related
I'm a noobie to Java and I had some questions, I think they may be easy (duh) answers to you experts but for me, I couldn't figure out the answer.
What is the point of Java programs, all I am making in my class now are simple read text files, have user input some stuff on the command line and the program prints out something. Like, it's cool and all that I can make a program do this but what does this all lead up to?
Say, I create a java program that converts celcius to fahrenheit and I want to have someone use it. Would I be able to get someone to use it that has no knowledge of Java, that is to say, giving it to my mom and she can run it from her computer without using Eclipse? How do I have someone who has no knowledge of coding run my program?
And my last question is, what is the point of command line arguments? Instead of putting them in the arguments, why not just have it in the code itself? Is it because if the code is big, it might be hard to find it? And if I download code that requires argument input, is it possible to download the code with the arguments set in Eclipse or would I have to manually do it?
Thanks, sorry for the long paragraph, but just wanted to put my thoughts down.
I think the short answer is modularity. Compiling or building a Java program takes time and knowledge (like you mentioned, someone who has no knowledge of Java probably wouldn't know what to do).
Passing in command line arguments allows you to just send someone the binary distribution of your program and passing in their own parameters without having to know what your code looks like or have to modify it.
In real life, programs aren't run from Eclipse (obviously), they're usually packaged into jars or wars and executed from the command line or some kind of app server.
If you download code that requires command line arguments, you will probably have to put them into Eclipse yourself, but hopefully the application has some documentation or help usage that explains what the arguments should look like.
You can create your own jar files that you can run from the console.
One of the simpliest ways to make your program usable without using Eclipse is with the Windows command prompt or Linux terminal:
go to you working directory (where your java file is stored)
Type javac (Example:javac hello.java) -This would compile your program
Type java (Example: java hello) - This will start it
Using of args is when you want to set some information to your program with the launching of the program.
Another way to start your program without using Eclipse is to make your own executable jar. With this you will get something like .exe file From which you can start your aplication
Most of the java programs are started from the CMD / terminal, or runs on java servers. There are aplication which have their own user interface (SWING, SWT, AWT ...) .
Most popular types of Java usage is creating a serious bussiness software, android aplications, complex web aplications etc.
what is the point of command line arguments?
Benefits of using Command line.
if I download code that requires argument input, is it possible to
download the code with the arguments set in Eclipse or would I have to
manually do it?
Right Click on project-name > Run > Run Configuration > select Arguments tab
For more info click here.
What is the point of Java programs, all I am making in my class now
are simple read text files, have user input some stuff on the command
line and the program prints out something. Like, it's cool and all
that I can make a program do this but what does this all lead up to?
This is just the begining. Learn Java core. Get familiarized with Java. One day you will be building tools using Java. eg:- Apache
How do I have someone who has no knowledge of coding run my program?
Compiling a java program into an executable
Before you do any this, get a book on Java (my fav - Java The Complete Reference) and read it. Learn how Java works, why is it different from other languages, best practices etc...
After 2-3 years from now, you'll get the importance of taking a small step by building simple cmd line programs using Java
I'm trying to build a simple text editor using Scala's swing library and I have to support two side by side windows. I was wondering if it was possible to have the second window be the terminal (bash, Unix). I haven't been able to find any information on the subject. Thank you for any information.
The question is: What is "the terminal"? bash is a shell but you need an implementation of a terminal which runs a certain shell. In general, I would say there are two possibilities:
Find a terminal implementation, which can be used directly in Swing. Maybe you this or that may help.
Implement your own terminal. You may want to start to wrap the shell with a ProcessBuilder. Now you can redirect standard input and output of this process so that you can control it programmatically (more information: here and there). Then you have to create the UI part which (1) reads input from the user and (2) displays the shell output in your window.
I am writing/planning to write a program that takes in a java file (or multiple java files), and edits and adds functions/classes/variables and then outputs a new java file (or multiple files).
Is there a C++ or Java library that
Can recognize and output names of classes/functions within a text file
Can recognize and output the names of the input arguments for said classes/functions
Can allow me to insert code at specific lines or within specific functions
Can search for a given variable name/value
Maintains original file formatting
I would prefer not having to manually code something to do the above, so any help would be appreciated.
Thank you in advance!
EDIT: I currently use Eclipse, and am unsure of how to proceed. So to further explain my question:
In eclipse, if I write a program that opens another .java file, How would I go about 'asking' eclipse to output, say, all the class names of the .java file I just opened?
Also I will explain the 'purpose' of this project to further clarify. I want to write a program that can take in any java file, and turn it into a class that can implemented remotely via RMI. To do this I will need to add an execute() function, have the file implement Task and Serializable and add a few variables, etc... Based on my knowledge, doing this in Eclipse would require manual editing of the program, but I would like to completely automate this process.
Thank you, again.
Much of what you need can be found in a modern IDE; and some very good IDEs are open source (eclipse and Intellij IDEA Community Edition for Java). You might look there to see if there are modules that suite your needs.
Looks like you are talking of a tool like eclipse. You might not be looking for a full fledged IDE, but the requirements that you have mentioned are fulfilled by any basic IDE.
If you wish to make one of your own, you can do that using eclipse rich client platform.
All that you would need from Java is the reflection API.
Trying to figure out my way around Sphinx 4 (the CMU speech recognition engine in Java), I tried to use a demo included with the distribution by altering it to what I wanted it to do (the name of the demo is Aligner). I am running into problems and want to use jdb from the command line for debugging the same. I read the documentation given here, but it is limited and does not have a solution to my problem, which in brief is as follows:
I invoke jdb like so:
jdb Aligner (name of the main class of the project).
Set a breakpoint like so: stop at Aligner:33
The output I get (on the command line):
Deferring breakpoint Aligner:33.
It will be set after the class is loaded.
In the file demo.xml (which is the makefile equivalent for this Project),
javac debug=true is mentioned.
My questions:
1. Where should I invoke jdb from? Should it be invoked from anywhere in the entire sphinx directory or should I invoke it from the same directory as Aligner.java?
2. How can I use jdb with the jar for this project?
P.S: I know I can use Eclipse with this, but I am not sure I know how to do that. My first priority is to get this up and running.
P.P.S: I am a Java newbie and do not know much about the language. My preference for the command line comes from my background of C/C++ programming on the command line.
Any help is most welcome,
Thanks!
What are you actually trying to do?
If you are not so familiar with Java, why not use Sphinx3 or pocketsphinx, both of which are implemented in C?
http://cmusphinx.sourceforge.net/wiki/download/
Also, you might get better responses on this topic by checking the forums on the above site, or checking in to the IRC channel #cmusphinx
Finally, you mention that your program name is 'aligner', which makes it sound like maybe you are trying to do forced alignment? There are already existing tools for this in the sphinx3/sphinxtrain/pocketsphinx packages and it would probably be worth your while to check them out.
I'm creating a Java application that helps people to learn Chinese. I've already created a Java GUI but I'm struggling to work out how to create a button that launches an external application in a new window.
I've looked up various tutorials on process, desktop and runtime but they all seem to deal with outputting data on the console, and I can't figure out how to apply them to this case.
Any help at all would be greatly appreciated! Thanks!
EDIT
So I've incorporated the runtime code into my class and I've got it to list the contents of my file but can't get it to launch the application using "/home/kate/Desktop/PTAMM ./PTAMM" or "./PTAMM /home/kate/Desktop/PTAMM" or "./ home/kate/Desktop/PTAMM PTAMM" (I tried the last two out of desperation). Any suggestions? Thanks!
Here you go
Runtime.getRuntime().exec("command to launch executable");
See
API doc
I've looked up various tutorials on process, desktop and runtime but they all seem to deal with outputting data on the console,
No that is wrong! Desktop.open(File) ..
Launches the associated application to open the file.
(Emphasis mine)
So Desktop.open(new File("word.doc")) might open MS Word or the Open Office Writer, while Desktop.open(new File("spreadsheet.xls")) might pop MS Excel of OO Calc.
To play with the Desktop class, try the code on the File Browser GUI thread.
If you decide to go with using Runtime. I suggest:
Read & implement all the advice shown in When Runtime.exec() won't.
Use ProcessBuilder to construct the Process. ProcessBuilder even has a convenience method to merge the output streams, to make them easier to 'consume'.
You might conclude after reading that article that usingDesktop is the simpler option. There are many traps & pitfalls involved with using a Process. ;)