[英]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.