In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
How to run java under Linux? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!
Recently, I have been in preliminary contact with linux, and I feel very fresh. The things I have done under windows also want to be implemented in the linux environment. I happen to be compiling java on hand, so I wonder if java can be run under windows's DOS operation, can it also be compiled and executed under linux's terminal? Curiosity is the best teacher, and the rich resources on the Internet have helped me to achieve this operation quickly.
The specific implementation process is as follows:
Install JDK
To compile and execute java code, you first need a system program that supports java, and that's what the so-called jdk,java development kit is for. Whether under windows or Linux, jdk is a must to compile and execute java code.
Jdk shields programmers from the differences between the two systems, so that java can be written once and compiled everywhere. The JDK package can be downloaded from the official website and different installation packages can be downloaded according to different systems. The method of installation varies slightly according to the version of Linux. I use the RedHat Linux (RHEL 6) system. Download the corresponding .rpm file and install it just like other software:
Rpm-ivh jdk_8u25.rpm
Use other systems, such as Ubuntu, to download the .tar.gz package for installation. There are a lot of materials online, so I won't repeat them here.
Generate JAR file
Once the jdk is installed, we can copy the code from windows to linux. Here we don't copy the .java code directly to the destination directory, but change it into a jar package, and then transfer it.
Here we use Eclipse to do this. To export the project source code to a jar package under eclipse, you can select the project right-> export- > jar. Generate the required 1.jar, and then prepare some additional jar packages, such as some commonly used lucene and mysql-connecor jar packages (you can also package these packages into a package), and copy these packages to the same directory in linux (or upload them to the linux server).
In addition, copy the main class file of the java code (including main functions, such as main.java) to the same directory
Compilation execution
Execute. First, you need to execute javac to generate a .class file. The format is as follows:
Javac-cp / home/username/../1.jar:/home.username/../2.jar:/home.username/../3.jar main.java
So the java program runs.
Thank you for reading! After reading the above, do you have a general idea of how to run java under Linux? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.