简体   繁体   English

如何在不使用IDE的情况下在Linux上运行Java项目

[英]How to Run a Java Project on Linux Without Using IDE

I am new to Java. 我是Java新手。 Basically, I developed a java projects which contains multiple Java packages inside Eclipse. 基本上,我开发了一个java项目,其中包含Eclipse中的多个Java包。 The project runs OK on my desktop with a redhat Linux installed. 项目在安装了redhat Linux的桌面上运行正常。 However, I need to run it on a more powerful Linux server (redhat enterprise Linux) which does not have X11 installed. 但是,我需要在没有安装X11的更强大的Linux服务器(redhat enterprise Linux)上运行它。 Therefore, it is impossible to run Eclipse on that server. 因此,无法在该服务器上运行Eclipse。 Is it possible to do that? 有可能吗? If so, how can I move the entire project to that server including the input and output folders? 如果是这样,我如何将整个项目移动到该服务器,包括输入和输出文件夹?

Thanks 谢谢

In Eclipse use the "Export Runnable Jar" option. 在Eclipse中使用“Export Runnable Jar”选项。 Highlight your project then click file->Export, choose Java, choose Runnable Jar file. 突出显示您的项目,然后单击文件 - >导出,选择Java,选择Runnable Jar文件。 Otherwise you can also use the javac compiler to compile your project and run it with the java command and your main class. 否则,您也可以使用javac编译器编译项目并使用java命令和主类运行它。

You will need to install the JRE on the machine you want to run it on. 您需要在要运行它的计算机上安装JRE。 This can be done with the following command: 这可以使用以下命令完成:

yum install java-1.6.0-openjdk*

Once you have java then it is simply a matter of executing your application. 一旦你有了java,那么这只是执行你的应用程序的问题。 I would recommend using eclipse to compile your project to a jar and use the following command to execute it: 我建议使用eclipse将项目编译为jar并使用以下命令执行它:

java -jar *JarFileName*.jar

Running Java is nothing to do with Eclipse . 运行Java与Eclipse无关。 You can run your java program in linux machine by opening terminal . 你可以通过打开终端在linux机器上运行你的java程序。

Step1;- Set your JAVA_HOME in your bash profile . 第1步; - 在您的bash配置文件中设置您的JAVA_HOME。

Step2:- open terminal , go to the folder or package where your main program is present. 步骤2: - 打开终端,转到主程序所在的文件夹或包。

Step 3:- compile it using javac -cp lib.jar Filename.java 第3步: - 使用javac -cp lib.jar Filename.java编译它

Step 4:- After compilation class file will be available , run it using java filename.java 步骤4: - 编译后的类文件可用,使用java filename.java运行它

Usually IDE like eclipse is for development not for running the application , but Linux version of eclipse is also available 通常像eclipse这样的IDE用于开发而不是用于运行应用程序,但也可以使用Linux版本的eclipse

http://eclipse.org/downloads/?osType=linux http://eclipse.org/downloads/?osType=linux

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在没有IDE和几个软件包的情况下运行和编译Java项目? - How to run and compile java project without an IDE and with several packages? 如何在不使用IDE或命令提示符的情况下运行Java应用程序 - How to run Java applications without using an IDE or the command prompt 在Docker中使用本地IDE运行Java项目 - Run java project in docker and using a local IDE 在不使用IDE或CommandPrompt的情况下运行Java项目 - Running a Java Project without using IDE or CommandPrompt 如何在不具有Linux的IDE的情况下从Sphinx4编译并运行HelloWorld.java示例? - How to compile and run HelloWorld.java example from Sphinx4 without and IDE in Linux? 如何导出Java项目,使其无需IDE(netbeans)即可运行? - How do I export my java project so it can run without the help of the IDE (netbeans)? 我如何在没有IDE的情况下编译和运行Intelij IDEA Java项目? - How do I compile and run Intelij IDEA java project without IDE? 如何使用bash在Linux系统上构建/运行Java项目? - How to build/run a java project on linux system using bash? 如何在不使用IDE的情况下解决Java中的NoClassDefFoundError - How to solve NoClassDefFoundError in java without using IDE 如何在不使用IDE的情况下在Java中包含库 - how to include libraries in java without using an IDE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM