Java gui to call batch and shell by taking inputs from user - java

Hi I am new to Java. I have written a Jython script to update some configurations in Websphere. It is having a text file (property.ini) where I am giving inputs like : where is my profile, where is my war file and some data to do configuration. My Jython will read these properties and do the configuration.
I am calling this Jython through batch or shell depending on OS. Initially my batch/shell will set 1 property in Websphere which is a prerequisite, and then restart server, and then call my Jython to do the required configuration.
Now I need a GUI written in Java where whatever data the user was giving in property file should be given through the GUIand it in turn should call a batch file if it is windows, or it should call shell if it's Linux/Unix.

Related

Execute java application with one icon

I'm trying to replicate the behavior of Linux where we create an application launcher using Alacarte providing it the command and file name and Icon using batch
However I have never used batch.
The batch file is in the same directory as the java application.
The Batch contains the command as:
java -javaagent:app1.jar -jar app2.jar
Which does the job but It keeps CMD running in the background which during work I always accidentally close it which turns out closing the java app.
How can I can make it so it will disappear after launching the app and keep the app running
On Windows use javaw, as this will not open the console window. See also java vs javaw

not able to execute shell script

I've scenario where I execute my java code using shell script.
When I run that shell script from autosys, it runs fine. But when I try to run it manually from linux box, it says Java not found error.
And when I check manually java version in linux box, using java -version it says java not there.
How its possible that, same shell script is triggered by Autosys but not manually ?
May I know please, what type of configuration is this ? I'm I missing anything ?
It is possible that the Java could be installed for the autosys user only in which case it will not be accessible by another user.
The autosys user could have had some PATH variable (perhaps in the profile) that points to the Java binary, which might not be present in your current user. You might want to check your ~/.profile file (or) ~/.bashrc, ~/.bash_profile to see if there is PATH variable.
To debug, just include which java in your shell script and check the output when the autosys runs it. This will give you the path of the java binary.
(or) Simply login as your autosys user and execute the same script.
May be, you might also be missing some bootstrap commands before executing your script (like export PATH etc).

Run Java Application at Windows Startup

How can I make java application start with Windows, without needing user interaction in netbeans ??
Follow the below steps:
Create a *.jar file using Netbeans
Create a batch file with the following contents:
javaw.exe -jar path/to/file/your_jar_file.jar
Create a basic task in the Windows Task Scheduler. Select "When I log on" as the trigger. Set the action to starting a program, and choose your batch file as the program.

Feeding commands to WinSCP

I have Java Code that launch process of WinSCP tool and connects to a Unix machine and then call a xxxx.exe located on the Unix machine.
The problem is that xxxx.exe accepts a parameter of a type File. So I need to upload this to the remote machine and then passed to the xxxx.exe.... that is failing
and I'm trying to avoid the temporary folders as possible.
small Code
Process p = Runtime.getRuntime().exec("rTool\\WinSCP.com /script=folder\\code.txt < C:\\FILESTOUPLOADS\\upload1.txt" );
The login information goes in code.txt as supported by WinSCP.com
file redirection (i.e. the "<" symbol) is handled my the command processor, which Runtime.exec() does not use. As mentioned in comments already, first use the String[] version of exec so that you don't have issues with command parsing. second, you need to invoke the command processor to handle the file redirection (e.g. using "cmd.exe /k"), or handle it yourself in java.
Why not use ProcessBuilder to change working directory and set path of the file from that directory
public ProcessBuilder directory(File directory)Sets this process builder's working directory. Subprocesses subsequently started by this object's start() method will use this as their working directory. The argument may be null -- this means to use the working directory of the current Java process, usually the directory named by the system property user.dir, as the working directory of the child process.
Parameters:
directory - The new working directory
Returns:
This process builder

adding a java application to system configuration start up menu

I am creating a desktop application. I know how to add program to system tray, that consists of a continuous system process, I need instructions on how to add java code to system configuration startup menu. Like antivirus program which automatically executes on starting the system. would be of great help with example code
Write a batch file(.bat) which executes you java program. Add this batch file into the registry in such a way that it will be executed during system startup.
simply write following into your batch file
java filename
In linux you will hv to create a .sh script(executable) that will execute your java program.
put .sh in /etc/rc0.d using following commands
cp name.sh /etc/rc0.d/
chmod +x /etc/rc0.d/name.sh

Categories

Resources