6

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

fanchyna
  • 2,623
  • 7
  • 36
  • 38
  • 5
    If you package up the project as a jar you can execute it on the command line with `java -jar jarfile.jar`. Or do you need to edit the source on that machine as well? – thatidiotguy May 20 '13 at 20:19

3 Answers3

4

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.

KyleM
  • 4,445
  • 9
  • 46
  • 78
  • what about the input arguments, input files and output folders? I have one input argument, millions of input files and an output folder. Do I export everything into a .jar file? Or only the source folder? If I use "javac" how can I do multiple packages which contains tens of .java codes? sorry but I am new in Java. – fanchyna May 20 '13 at 20:38
  • @fanchyna Maybe this will help? http://stackoverflow.com/questions/945962/java-problem-running-a-jar-file-in-command-line .. Also you don't HAVE to use a runnable jar, read about javac you can compile lots of files at once... – KyleM May 20 '13 at 20:48
0

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
0

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

  • thanks. I know that you can easily compile a java program using your way, but I was asking the way to do a java "package", which contains many .java codes. Thanks. – fanchyna May 20 '13 at 20:36