How to Run a Java Project on Linux Without Using IDE

拜拜、爱过 提交于 2019-12-12 10:53:51

问题


I am new to Java. Basically, I developed a java projects which contains multiple Java packages inside Eclipse. The project runs OK on my desktop with a redhat Linux installed. However, I need to run it on a more powerful Linux server (redhat enterprise Linux) which does not have X11 installed. Therefore, it is impossible to run Eclipse on that server. 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


回答1:


In Eclipse use the "Export Runnable Jar" option. Highlight your project then click file->Export, choose Java, choose Runnable Jar file. Otherwise you can also use the javac compiler to compile your project and run it with the java command and your main class.




回答2:


You will need to install the JRE on the machine you want to run it on. 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. I would recommend using eclipse to compile your project to a jar and use the following command to execute it:

java -jar *JarFileName*.jar



回答3:


Running Java is nothing to do with Eclipse . You can run your java program in linux machine by opening terminal .

Step1;- Set your JAVA_HOME in your bash profile .

Step2:- open terminal , go to the folder or package where your main program is present.

Step 3:- compile it using javac -cp lib.jar Filename.java

Step 4:- After compilation class file will be available , run it using java filename.java

Usually IDE like eclipse is for development not for running the application , but Linux version of eclipse is also available

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



来源:https://stackoverflow.com/questions/16657636/how-to-run-a-java-project-on-linux-without-using-ide

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!