English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
To run Java programs on Ubuntu, you can compile the Java program successfully, package it, and then execute the jar file using the command on Ubuntu
Specific operations are as follows:
1How to compile Java projects using eclipse on Windows, and export them as Runnable JAR File after compilation
For example, here the Test in the test project is exported as a Runnable JAR File2Export the file as MyTest2.jar file
2Ubuntu Java environment installation
①JDK official website http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html to download JDK for Linux
②eclipse official website http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/heliossr1/Download eclipse for Linux
③ Upload JDK and eclipse to the Linux server, unzip them, and then configure the java environment variables (e.g., the unzip directory of JDK is/home/test)
Configuration method: edit/etc/Add the following content to the profile file (Note: The colon : is used to separate paths in Linux, and the dot . represents the current directory)
export JAVA_HOME=/home/test/jdk1.8.0_65
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
Save the file after editing
④ Make the configuration take effect, command source /etc/profile
⑤ Test if the environment variable is configured successfully, command java -version
If the JDK version is displayed, it means that the java environment variable is configured successfully
3Execute the jar file exported by the java project on Ubuntu
Command: java -jar MyTest2.jar
The above-mentioned methods of executing java programs under Linux introduced by the editor are for your reference. I hope it will be helpful to you. If you have any questions, please leave me a message, and I will reply to you in time. I am also very grateful for the support of everyone for the Naihua Tutorial website!
Statement: The content of this article is from the Internet, the copyright belongs to the original author. The content is contributed and uploaded by Internet users spontaneously. This website does not own the copyright, has not been manually edited, and does not assume any relevant legal liability. If you find any content suspected of copyright infringement, please send an email to: notice#oldtoolbag.com (Please replace # with @ when sending an email to report abuse, and provide relevant evidence. Once verified, this site will immediately delete the infringing content.)