In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of how to compile and run the Eclipse Java project in Linux, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will have something to gain after reading this article on how to compile and run the Eclipse Java project in Linux. Let's take a look.
Command line used
Basically, you need the following two commands. The-cp option configures the classpath, which points to the class and jar files used. If you use multiple libraries, each library should be included and separated by ":".
Javac-cp "all jar file's path" package/target.javajava-cp "all jar file's path" package.targetjavac-cp "/ home/pc/workspace/TerminalEclipse/lib/commons-io-2.4.jar:/home/pc/workspace/TerminalEclipse/lib/commons-lang-2.5.jar" package1/Test.java A sample Eclipse project
Next I created a Java project under eclipse. The project contains a class Test, which is located in package1. This Test class uses / lib / some third-party libraries.
First, cd to the / src/ directory and compile the project using the following command.
Javac-cp "/ home/pc/workspace/TerminalEclipse/lib/commons-io-2.4.jar:/home/pc/workspace/TerminalEclipse/lib/commons-lang-2.5.jar" package1/Test.java
Second, run the project using the following command.
Java-cp ".: / home/xiaoran/workspace/TerminalEclipse/lib/commons-io-2.4.jar:/home/xiaoran/workspace/TerminalEclipse/lib/commons-lang-2.5.jar" package1.Test
* Note: the first part of the path is. Point to the current path.
The compilation process generates .class files in the / src/ directory. When you use eclipse again, you may want to delete it.
Potential problem
If you are developing a large project, you may use a lot of third-party libraries. You can use the following code to generate a path string.
Public static void printAllJars () {String str = "/ home/pc/workspace/TerminalEclipse/lib"; File file = new File (str); StringBuilder sb = new StringBuilder (); File [] arr = file.listFiles (); for (File f: arr) {if (f.getName (). EndsWith (".jar")) {sb.append (f.getAbsolutePath () + ":") }} String s = sb.toString (); s = s.substring (0, s.length ()-1); System.out.println (s);} this is the end of the article on "how to compile and run Eclipse Java projects in Linux". Thank you for reading! I believe you all have a certain understanding of "how to compile and run Eclipse Java projects in Linux". If you want to learn more, 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.