Good day! There was a problem with writing a script for executing a java program on a cluster. I have a project in eclipse, I make jar from it. Here is an example script that wrote (does not work):

#!/bin/sh /home/m/test/Test4.jar 

In addition, the project also has third-party libraries, which I do not know how to include in the script ..

  • one
    Comments to my answer are over, so I will write here. You have completely confused me. If the program is written in OpenMP, it is executed not on a cluster, but in several threads of the same machine. If you performed it on a cluster, then the script that you led to launching the program on several machines has no relation whatsoever. Let's define the terms in which we communicate. - fori1ton
  • A program written in OpenMP can also be run on a cluster. The script resulted in the launch of the program, and the number of nodes and involved cores are directly through the command in the command line, i.e. like this:> qsub -l nodes = 5: ppn = 4 hello.run (5 nodes and 4 processes on each of the nodes) - Stas0n
  • one
    There is a contact! Now we realized that the program did not just work on a cluster - it worked under OpenMP! Now it remains to realize that a Java program will not just work on a cluster - it also needs something like OpenMP. In the case of Java, this is JOMP, JPPF, Hadoop. Well, or bicycles with copying the program to all the machines in the cluster and manual distribution of tasks to each machine. - fori1ton
  • Precisely, added the answer. The last problem remains - how to add third-party libraries - Stas0n

2 answers 2

The jar file itself is not executable. You need JRE to run. Running the jar file from the command line looks like this:

 java -classpath /путь/к/сторонним/библиотекам/ -jar Test4.jar 
  • What is the difference on what to run? - BiMaWa
  • one
    If execution should take place on a computing cluster, then standard OS and Java tools are indispensable. Read about [Hadoop] [1]. [1]: en.wikipedia.org/wiki/Hadoop - fori1ton
  • one
    How did you run this program in C ++ on a cluster? Just calling it on the command line? Then I hurry to upset you - it was performed only on the computer on which you started it. - fori1ton
  • one
    Script in the studio! - fori1ton
  • one
    That is, you manually copied this script along with the program on all the cluster machines and manually started it on each machine? Your perseverance can only envy. You can do the same with your java program. Remember that the JRE must be on each cluster machine. Or you can stop reinventing the wheel and take advantage of a ready-made solution. For Java, Hadoop; for C and other compiled languages, OpenMPI. - fori1ton

Still, I solved one problem: I was able to run it using a script, here it is:

 #!/bin/sh export LIBJARS=/home/m/joda-time-2.2.jar export HADOOP_CLASSPATH=/home/m/joda-time-2.2.jar hadoop jar /home/m/testing.jar test/Test4 -libjars {LIBJARS} 

It remains to understand how to solve the problem with link libraries.

  • The problem with plug-in libraries is solved with the libjars option: hadoop jar /home/mikhailyuk/testing.jar test / Test4 -libjars YOUR LIBRARY - fori1ton
  • one
    Here is [article] [1], describing at once three ways to connect third-party libraries. Here is [official documentation] [2] describing the Hadoop command line options. Here is [Google] [3] in which you could find all this in five minutes. [1]: blog.cloudera.com/blog/2011/01/… [2]: hadoop.apache.org/docs/stable/commands_manual.html [3]: google.com - fori1ton
  • Yes, I just read this article here: blog.cloudera.com/blog/2011/01/… Follow the 1st method, for some reason it does not start .. Do I understand correctly that the library needs to be located on the node and “ -libjars ”specify the full path to it? - Stas0n
  • Here is an example:> #! / Bin / sh hadoop jar /home/mikhailyuk/testing.jar test / Test4 -libjars /home/mikhailyuk/joda-time-2.2.jar - Stas0n
  • It seems not on the node, but on the server. It says that such a library gets into the distributed cache and becomes available to all nodes. - fori1ton