How to implement Java code in the background of RedHat (LinuxONE)


If it is a process like uploading a large number of images, it will take hours to execute the code, and it may interfere with other work. This time, I will describe how to implement Java code in the background of Red Hat and do other work locally while executing Java code, so please refer to it.

Server construction

For server construction and server login, please go to the following URL. This time, build a RedHat server with LinuxONE and log in to RedHat with TeraTerm.

Allow local files to be moved on the server

Since WinSCP is used to move the local file on the RedHat server and to move the file on the server locally, build the WinSCP environment.

Key conversion

  1. Install PuttyGem. Please refer to the following URL for the registration method.
  2. Create a .ppk file. Select Conversions → Import key. linuxone2.png
  3. Specify the .pem file created when building the server. putty_re2.png
  4. Enter the password for the .pem file. putty_re3.png
  5. After importing, enter any "key_passphrase" and "Confirm_passphrase" and click "save private key". putty3.png
  6. When the file save screen appears, enter an arbitrary name in "File name", specify the ".ppk" format in "File type", and click the "Save" button. putty4.png
  7. I was able to create a "ppk" format file from a "pem" format file. putty5.png

install winSCP

Please refer to the following URL for the registration method.

Log in to the server with winSCP

  1. Start winSCP.
  2. Specify SFTP in "Transfer Protocol", enter the IP address of the Red Hat server built with LinuxONE in "Host Name", and enter the user name set in Tera Term in "User Name". winscp1.png
  3. Click "Edit" and specify the private key. Click "Set". winscp2.png
  4. Click "SSH"-> "Authentication", specify the file converted to ppk format by puttyGen in "Private Key", and click "OK". winscp3.png
  5. Click Save> Login. winscp4.png
  6. Enter the password for the private key and click the "OK" button. winscp_ew1.png
  7. This is the screen when accessing the RedHat server with winSCP. rewinscp1.png
  8. When you can access the server, the following screen will be displayed. The left side is the local directory and the right side is the directory on the server. winscp5.png

Preparing the code to execute

Compress the execution project

  1. Open eclipse.
  2. Select File → Export. Select General → Archive File and click Next. archive1.png
  3. Select the project to be compressed, specify the directory to create the file and the zip file name in "To archive file", and click "Finish". archive2.png
  4. Copy the zip file to your server. You can copy the zip file to be executed by drop and drag. winscp6.png


  1. Create a file. Create a "" file, specifying which code in the project you want to run. The code below is an example of how to fill in the file, where "FILENAME" shows which file to execute, and "\ $ 1 \ $ 2 \ $ 3" shows the arguments. entry example


cd demoApp/target/classes

java -classpath .:../../lib/commons-codec-1.4.jar:../../lib/commons-httpclient-3.1.jar:../../lib/commons-logging-1.1.1.jar:../../lib/mysql-connector-java-5.1.21-bin.jar:../../lib/httpclient-4.5.1.jar:../../lib/httpclient-cache-4.5.1.jar:../../lib/javase-3.3.0.jar:../../lib/httpcore-4.4.3.jar:../../lib/httpmime-4.5.1.jar:../../lib/json-simple-1.1.1.jar FILENAME $1 $2 $3

cd ../../..

2. After saving, copy the file onto the server. winscp7.png

Now you are ready to run the code on the server.

Execution environment construction

Install Java on RedHat

  1. While logged in to RedHat with TeraTerm, install the same version as the Java version of the compressed code. Please note that if the Java version is different, "java.lang.UnsupportedClassVersionError" will occur.
 $sudo yum install java-1.8.0-ibm-devel

   2. Click y when prompted to confirm the installation. java4.png
If the installed Java version and the characters "Completed!" Are displayed, the Java installation is complete.

Install screen on RedHat

Install screen while logged in to RedHat with TeraTerm.

 $sudo yum install screen


Run Java code in the background of RedHat

Run screen

If you execute the command as it is in RedHat, it cannot be in the state of being executed in the background, so execute the command in the screen.

  1. Since screen will be executed, execute the following with the command.

   2. When you run screnn, "screen 0" is displayed at the top. screen2.png The screen is now running.

Decompress the compressed file

  1. After running screen, check the current directory with "ls". At this time, if the zip file copied to the server does not exist earlier, move to the directory one level above the zip file copied to the server. screen4_1.png
  2. Extract the zip file, so execute the following code. Change FILENAME to your own zip file name.
 $unzip FILENAME


Run the file

  1. Execute the following code to add permission to execute the file.
 $chmod +x

2. Run the file. By executing, you can execute the file specified in the file on RedHat.


   3. Please refer to the following URL for detaching and attaching. 3-1. Detaching method
3-2. How to attach
   [link-detach]: [link-attach]:

Recommended Posts

How to implement Java code in the background of RedHat (LinuxONE)
How to find the optimal number of clusters in k-means
How to run TensorFlow 1.0 code in 2.0
[For beginners] How to implement O'reilly sample code in Google Colab
How to handle multiple versions of CUDA in the same environment
How to determine the existence of a selenium element in Python
How to know the internal structure of an object in Python
How to change the color of just the button pressed in Tkinter
How to check the memory size of a variable in Python
I wrote the code to write the code of Brainf * ck in python
How to check the memory size of a dictionary in Python
[TensorFlow 2] How to check the contents of Tensor in graph mode
How to get the vertex coordinates of a feature in ArcPy
How to display bytes in the same way in Java and Python
How to check the version of Django
Implement part of the process in C ++
How to implement nested serializer in drf-flex-fields
How to implement Scroll View in pythonista 1
How to compare if the contents of the objects in scipy.sparse.csr_matrix are the same
How to calculate the volatility of a brand
How to use the C library in Python
How to find the area of the Voronoi diagram
How to implement Rails helper-like functionality in Django
How to implement Discord Slash Command in Python
Summary of how to import files in Python 3
How to implement shared memory in Python (mmap.mmap)
Summary of how to use MNIST in Python
How to implement a gradient picker in Houdini
How to implement "named_scope" of RubyOnRails with Django
How to get the files in the [Python] folder
[Java] How to switch between multiple versions of Java
How to pass the execution result of a shell command in a list in Python
How to make VS Code aware of the venv environment and its benefits
How to mention a user group in slack notification, how to check the id of the user group
How to uniquely identify the source of access in the Django Generic Class View
Use the Java SDK of GoogleMapsAPI to get the result of reverse GeoCoding in Japanese.
How to count the number of elements in Django and output to a template
A memorandum of how to execute the! Sudo magic command in Jupyter Notebook
How to display in the entire window when setting the background image with tkinter
How to find the coefficient of the trendline that passes through the vertices in Python
How to change the appearance of unselected Foreign Key fields in Django's ModelForm
How to make the font width of jupyter notebook put in pyenv equal width
How to get a list of files in the same directory with python
How to install the deep learning framework Tensorflow 1.0 in the Anaconda environment of Windows
The background of the characters in the text image is overexposed to make it easier to read.
How to retrieve the nth largest value in Python
How to know the port number of the xinetd service
How to get the variable name itself in python
How to run the Ansible module added in Ansible Tower
How to measure processing time in Python or Java
How to know the current directory in Python in Blender
How to identify the element with the smallest number of characters in a Python list?
How to visualize the decision tree model of scikit-learn
Summary from the beginning to Chapter 1 of the introduction to design patterns learned in the Java language
How to start the code written in Atom with one command without starting teminal
How to display multiple images of galaxies in tiles
Implement the solution of Riccati algebraic equations in Python
How to use the exists clause in Django's queryset
[Note] How to write QR code and description in the same image with python
How to check the Java version used by Maven
[Blender] How to dynamically set the selection of EnumProperty