XLDeploy dar file creation using windows command prompt - java

Please refer the link:
https://docs.xebialabs.com/xl-deploy/how-to/create-a-deployment-package-using-the-command-line.html
Collect the EAR file and the configuration directory and store them in the directory:
cp /some/path/petclinic-1.0.ear petclinic-package
cp -r /some/path/conf petclinic-package
Now what is cp? Java command? Maven command? Windows command?
'cp' is not recognized as an internal or external command,
operable program or batch file.

cp is the Unix/Linux file copy command. The first line copies a single file. The second line with cp -r copies recursively: it copies the directory tree.
You can achieve the same with the windows "copy" command or by performing these steps manually in the windows explorer.

Related

How to prepare docker image/ container/ dockerfile with jar file

I'm new to Docker. I have a problem: I have a jar file that processes "in.png" and saves the result as a separate file: out.png. I'd like to create a docker image and put a .jar file in it. It is important that the in.png and out.png files appear / are delivered on the host side. I want to put everything on dockerhub, and ultimately allow the user to process their own graphic files. What is the best solution to this problem? I have tryed something like this (is it good solution?):
FROM java:8
WORKDIR /
ADD Hello.jar in.png
EXPOSE 8080
CMD java - jar Hello.jar
But i can't coppy (or i don't know how) output file from container to host;
Or maybe a better solution is make an image (Java / Ubuntu with Java?), uploading a .jar file to it and providing the user with a set of commands, e.g .:
docker cp Hello.jar 4e673836297e:/
docker cp in.png 4e673836297e:/
docker run ubuntu java -jar Hello.jar
docker cp 4e673836297e:/ .
Please tell me what the best solution is for this problem
You should mount a directory to your docker container using bind mounts.
If your jar writes the output to /output/out.png you can start a container based on your image with the following command.
docker run -v "$(pwd)":/output YOUR_IMAGE_NAME
That option mounts the current working directory to the /outpout folder inside the container. So the files written there will be visible on the outside.
A more detailed explanation can be found here: https://docs.docker.com/storage/bind-mounts/
Edit to answer the additional question:
You can also use the mounted folder for the input, so you can have different image files as input.
First the simple aproach.
Instead of naming the folder output, you could name it workdir and mount the current directory to it.
docker run -v "$(pwd)":/workdir YOUR_IMAGE_NAME
When you have to change your java application to read the in.png from /workdir/in.png. The user has to save his individual input file as in.png in the current folder and can then run the Docker image.
A more advanced and more comfortable aproach is the following.
You change the Dockerfile so it contains an entrypoint and a command.
FROM java:8
WORKDIR /
ADD Hello.jar in.png
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "Hello.jar"]
CMD ["in.png"]
When this docker image is executed, it starts java -jar Hello.jar but with the parameters from the CMD added. The CMD can be overwritten when the image is executed:
docker run -v "$(pwd)":/workdir YOUR_IMAGE_NAME custom.png
You have to change your programm, so that it accepts the first command line parameter as the name of the input file inside the workdir.
Then the user can tell your progamm the name of his or her image file.

Execute a .jar file using shell script

I want to execute a jar file of DOMO CLI from a shell script. The jar file itself has some functions which I want to call after I call the main jar file. The problem which I am facing is that after it executes the jar file, I am not able to pass the additional commands to execute inside that jar through a shell script. It just stops after calling jar and doesn't take further commands. Can anyone please help? Below is the code I am calling from a shell script.
java -jar XX.jar
The commands are as below which follow the above jar. So once we enter into the above jar we have to execute the below commands one after the other. I am not sure how to achieve this through a shell script.
connect -s X.domo.com -t Ysssss
upload-dataset -a -i dhdhdhdh -f /prehdfs/dev/comres/herm/data/yyyy.csv
Did you try using pipes and inputs.
When you execute above it runs it under a child shell.
You may try below format if not tried already
$ (echo "connect -s X.domo.com -t Ysssss" && cat) | java -jar XX.jar
If you can reference a file in your use case, you could put your commands in a file.
File: list_my_datasets.domo
connect -t ... -s ...
list-dataset
quit
then run the command:
java -jar domoUtil.jar -script list_my_datasets.domo > datasets
I wanted the data from it so I piped to a file (where I had to grep what I wanted), but you would omit that I believe, unless it has some output you'd want to check. I haven't tested with the upload command, but I would hope any commands substituted or added to the example work similarly.
Domo docs on scripting

Create a Run file in java

Is there a way to create a "Runfile" in java which runs the program just by using a command run, like Makefile and make?
I am using linux and have to type this command very often java -cp ../lib/*:../zookeeper-3.4.6.jar:. WordCount. It would be convenient if there was a easier way!
Make a shell script name run and place your required command.
Now make the run script executable -
chmod u+x run
Now you just execute the shell script from the terminal. If you need further improvement and if you are in ubuntu then you can create a bin directory at your home (~). Then you can place all of your commands in it. Generally your ~/.profile file contains information about the bin directory at your home. Now the bin directory works as your private bin. If your ~/.profile file doesn't contain any information about the bin directory then you can add the following line in your ~/.profile -
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi

Shell script to launch Java app won't execute

I am using debian and xterm.
I have created a file 'run.sh' containing the following:
java -cp bin Main
read -n1 -r ip "Press any key to continue..." key
In Properties window I gave it permission to run as program.
Double clicking the file does nothing. Right click 'Execute' does nothing. Open-with UXTerm does nothing.
If I open a terminal in the same directory and type
java -cp bin Main
then it will run, but the shell script file never works.
What am I doing wrong here?
Your shell script file doesn't seem to have a shebang line,
#!/usr/bin/env bash
java -cp bin Main
read -n1 -r ip "Press any key to continue..." key
and make sure it has a execute permissions
chmod a+x <script_file>
You need to add a shebang line at the top of your file: #!/usr/bin/bash. This tells the operating system that the file is in fact a bash executable rather than a normal file. Alternatively, execute the script by entering bash run.sh from the command line.

Script Not Running

I have a script file that I would like to run whenever my computer starts up. What the script file does is run a .jar file that I have on my desktop.
I first created a .jar file called Hello.jar that is located on my desktop. After that I created a script file (.sh) called Script.sh that has the following contents in it.
cd Desktop;java -jar Hello.jar;
Then I followed this answer to run the file on startup. So as it says I first setup a .desktop file by running this command in the terminal.
sudo cd Desktop
sudo mv Script.sh /usr/bin
Then I did
sudo cd /usr/share/applications
sudo gedit file.desktop &
Then I wrote the following information in gedit.
[Desktop Entry]
Name=Hello.sh
Exec=/usr/bin/file.sh
Type=Application
Terminal=false
And lastly I created a copy of it in this location.
/etc/xdg/autostart/
I then restarted my computer but nothing happened.
sudo cd doesn't do anything! The cd command only takes effect within the current shell - which immediately exits!
Instead you should do sudo bash to launch a root shell. Then run all your commands within that root shell.
Also, I think you forgot to give your script execute permissions. You can do that by changing mv to install.

Categories