473,573 Members | 4,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Java GUI and typing console commands

13 New Member
I have sucessfully launched a jar file from a C program, but now i need to figure out how to actually type commands into that console. I tried using the robot class, but when the GUI window is up it will not type into the console window.......

Any help would be greatly appreciated, thank you!

-Doug
Jul 23 '08 #1
15 6183
beavis601
13 New Member
I guess to hopefully clarify......If button1 is pressed i want to type in "year 2008" and hit return so that the program takes that as a command. Hope this clears it up.

doug
Jul 23 '08 #2
BigDaddyLH
1,216 Recognized Expert Top Contributor
Let me get this right, because it sounds completely crazy. You have a program with a GUI interface that want to simulate typing onto a console window?! Why?
Jul 23 '08 #3
beavis601
13 New Member
Its for a program that was already written, and instead of having to type in the command "play" or "pause", they want me to have a GUI that if you press the play button it will have command passed.....
Jul 24 '08 #4
r035198x
13,262 MVP
Its for a program that was already written, and instead of having to type in the command "play" or "pause", they want me to have a GUI that if you press the play button it will have command passed.....
You thus need to write an event listener for your play and pause buttons.
You can read about how to do that here.
Jul 24 '08 #5
BigDaddyLH
1,216 Recognized Expert Top Contributor
Its for a program that was already written, and instead of having to type in the command "play" or "pause", they want me to have a GUI that if you press the play button it will have command passed.....
So the earlier program is console based?

You can solve this by piping the programs -- no need to use Robot, which would be a fragile and tedious solution. To pipe the output of program one as the input of program two, execute on the shell level

Expand|Select|Wrap|Line Numbers
  1. program1 | program2
That's it! Notice this is a general solution, independent of Java. So if you want Java program GuiApp to send its System.out as the System.in of ConsoleApp, write:

Expand|Select|Wrap|Line Numbers
  1. java GUIApp | java ConsoleApp
Jul 24 '08 #6
beavis601
13 New Member
I understand how to write GUI's and use actionlisteners ......The one thing I know how to code the java program to write in a command in C. Is there a way to actually have the command passed as

C:\ year 2008

or something very similar.

Its my last week at work and I just really want to get this working, thank you so much for all the help!

Doug
Jul 24 '08 #7
beavis601
13 New Member
BIGDaddy

Thank you! Piping the programs is a great idea, and seems to be a quite simple solution to my problem. Do you know how to actually pass a command in java though? I dont want to just write to the console, I want to actually have a command passed.

Thanks for all the help!

Doug
Jul 24 '08 #8
BigDaddyLH
1,216 Recognized Expert Top Contributor
BIGDaddy
Do you know how to actually pass a command in java though? I dont want to just write to the console, I want to actually have a command passed.
I don't understand what you mean by "pass a command". Can you give an example?
Jul 24 '08 #9
beavis601
13 New Member
for example if you open command prompt and you type "cd .." it performs change directory, or if you type "dir" it shows what in the current directory. I am working with a custom console, but I essentially want to be able to pass the same type of commands once a certain button is pushed.

I'm sorry this isn't very clear, I'm just a student and am at a summer job working on this project.


Doug
Jul 24 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

11
167080
by: Lem | last post by:
I get the error Exception in thread "main" java.lang.NoClassDefFoundError when I type java app2 in the command prompt. I've tried moving to the jre directory and typed java c:\app2\app2, but it gives me the same exception. What could be the problem? Thanks in advance, Lem
13
6578
by: BlackHawke | last post by:
Our program, game program Andromeda Online (www.andromedaonline.net) uses two programs- one to play the game, another to patch the game as updates come out. Players actually launch the updater which checks for fresh updates, then installs them, then launches the game client. We have begun our beta test, and would like to have the client open...
114
9735
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
28
4302
by: liorm | last post by:
Hi everyone, I need to write a web app, that will support millions of user accounts, template-based user pages and files upload. The client is going to be written in Flash. I wondered if I coudl get your opinions - what do you think is the best language to use for the server? Python or Java? And I'm talking scalability, object oriented,...
1
9610
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the...
26
3207
by: Christoph Zwerschke | last post by:
You will often hear that for reasons of fault minimization, you should use a programming language with strict typing: http://turing.une.edu.au/~comp284/Lectures/Lecture_18/lecture/node1.html I just came across a funny example in which the opposite is the case. The following is a binary search algorithm in Java. It searches a value in an...
16
3992
by: Amir Michail | last post by:
Hi, It seems to me that measuring productivity in a programming language must take into account available tools and libraries. Eclipse for example provides such an amazing IDE for java that it is no longer obvious to me that one would be much more productive in python for medium sized projects. Sure, all that Java static typing can be...
5
6269
by: r035198x | last post by:
Setting up. Getting started To get started with java, one must download and install a version of Sun's JDK (Java Development Kit). The newest release at the time of writting this article is JDK 6 downloadable from http://java.sun.com/javase/downloads/index.jsp. I will be using JDK 5(update 8)
3
5104
by: gisto moss | last post by:
i have to implement the shell such that it accepts commands, together with parameters. Assume all possible commands have either 0 or 1 parameter. I need to check this. if(commandstrings.length>2) {output error message and continue to the beginning of the loop} Note: the continue statement will skip all the following lines and go back to the...
0
7741
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7978
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8167
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8028
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5550
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3692
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2164
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1263
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
987
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.