I have Java console application but I need to create a user interface for the user interaction.
Is it possible to connect the GUI with Java console?
Not sure what the question is however,
You can use the console if you start with java.exe whether you use a GUI or not. If you use a GUI it is common practice to use javaw.exe which doesn't have a console, but you don't have to start your application that way.
On Unix there is only java ;)
You can connect jconsole ?Java Console? to either of these.
I have Java console application but I need to create a user interface for the user interaction.
If I understand you correctly, you have an application that takes input from the command line and you now need a GUI on top of it?
I'd say the easiest way to do this should be to create a new GUI app and use the exisiting application as a library. You might be able to call the console application's main method from the UI app and replace the standard input and output streams with your own implementations that connect to the GUI.
Related
I'm creating a simple notepad (just like a clone of the real one). As an advancement I decided to add a Java compiler and Runner in the app making it a very basic IDE. My problem is how to I tell Java that System.out.prinltn() should print it's results in my own console?
I know the question is short but this is what i wanted to know. Not only for System.out.prinltn() but for all the other things which are printed in the console.
Thanks in advance
You need to pass arguments to the your notepad application.
For that you need to use windows controllers to access your notepad application from another java application.
IF both of the application written in java then you can use TCP ip at the backrground to communicate. This is the only one way, there are alot of other ways.
I created a simple standalone Java application (JAR) that connects to a Honeywell barcode scanner over a virtual COM port (using RxTx libraries for setting up the COM connection).
After connecting, the program then receives the input from the scanner, transforms it using some custom logic and finally redirects the transformed output to the standard out using the Robot class. Nothing really complex.
So, if I run the program and then scan an value "A", the app transforms it into "B" and when notepad is active (or some other input field/program), "B" is outputted as if it was originally scanned by the scanner.
This program runs perfectly when run as a jar file (or wrapping bat file). However, when wrapping this JAR/BAT file as a windows service (using JSW Community Edition or YAJSW) the program will function perfectly, but will not output the "mimicked" keystrokes performed by the Robot.class.
I even used JNA libraries with the sendInput() method (as replacement for the Robot class) to create the keystrokes as close to the OS level as possbile, but this didn't work also... I also tried to make the service interactive but also this didnt work. Currently i am running out of options.
So my question is: is it correct that you cannot generate keyboard press events when running as a Windows Service? I could imagine that this could be a big security problem and maybe therefore it is disallowed.
Any feedback or possible solution would be very welcome! Many Thanks in advance!
It is a specification called session 0 isolation, which was introduced from Windows Vista.
Programs that act as WindowsService do not have a user interface.
Please refer to these articles and documents.
Application Compatibility – Session 0 Isolation
Session 0 Isolation - Microsoft Download Center
What is Session 0 Isolation? What do I need to know about it?
Session 0 Isolation and Secure Desktop: Windows 7 AppCompat Series
In Addition
Please try registering to Task Scheduler.
Register task in windows task scheduler in java
In that case, it may be ineffective unless it is "Run only when user is logged on".
This is an article on Windows Server.
show window of task scheduler schedule program.
However, there is a possibility that it will not work even if you do it.
Simple c++ program fails to run as a scheduled-task (interactive/non-interactive issue?)
I am having the same problem with this one >
Using Java Service Wrapper GUI to interact with desktop on windows
I am currently using Java Service Wrapper to wrap my Java program into a Windows Service. It has a requirement to get hold of an open Window and control it (i.e. press buttons).
I have made it an interactive service and even installed it as an admin user and still no success.
I am using JNA library to get the Windows instance which always returns null if it is running as a service but successful when triggered manually.
hWnd = User32.INSTANCE.FindWindow(0, targetWindowTitle);
One comment in that thread says , it needs to use Java RMI. Do we have examples on how to do it?
Thanks!
I am afraid that is not possible for security reason.
Take a look at the Java Service Wrapper wrapper.ntservice.interactive property documentation at https://wrapper.tanukisoftware.com/doc/english/prop-ntservice-interactive.html
I am quite a beginner, any advice is much appreciated.
I have a linux application OpenBTS used to simulate and run a GSM network on a software defined radio device e.g USRP.
I want to build an application that interfaces with the OpenBTS command line on Linux. I want to give the user an easier way to configure and to display the current configurations of the application. The user would have an interface in which he could play with the configurations without the need to use the terminal.
I don't know if this is possible ?
Is it possible to interact with a Linux CLI through a GUI ? If yes what is the most efficient programming language, coding technique or approach to do that ?
Thanks a lot
You could generate a config file using your GUI and then use standard in to get the configuration into OpenBts. When launching OpenBts with the configuration file config.txt you could simply run it as follows.
./OpenBts < config.txt
You could also do this from you GUI by launching OpenBts in a process from your GUI application in a similar fashion, however this requires a fork() and exec()
In C++, you can take inputs from user through GUI then run appropriate openBTS commands using system()/popen(). Based on the return values of system()/popen(), can provide status of the operation back to the user.
I would just like to know whether it is possible to make a command prompt in Java.
My friend asked to make it, I wanted to know if it was possible or not. If it is possible, can someone suggest me some api or something? Thank you.
EDIT: I want to make it similar to windows command prompt
EDIT 2: I would like to make a SWING GUI application and put a command prompt inside of it.
Yes. Use the Process API.
You can run commands in Java using the Process API. You can also get the output and write input to the runned process. For more info, see this tutorial.
But if you want to make a terminal emulator (such as those in Linux) in Java,
I recommend having a look at JCTerm or JTA.
You must be careful how you start it.
If you start your program with java.exe then the console (input/output) is shown. With System.out.println("mymessage"); you can print (output) text to the console. With System.in you can read from the console. This delegates to the java.io.Console class (available throug System.console()).
If you start your program with javaw.exe, then you don't see the console. You must then create your own screen to allow input/output. This is the default on Windows.
Java can do console I/O and it can launch processes, so yes, it's possible. You'd use methods of System.in and System.out to display a prompt and read commands, and a ProcessBuilder to execute programs.
yes it's possible in java
your have to do some research on Java.lang & IO
Check the class java.lang.Runtime. It provides a couple of exec() methods.