MPJ Express (Java MPI) running in Intellij IDEA
Asked Answered
O

1

6

I downloaded mpj-v0_44 and extracted it to C:\mpj

Put Windows system env. variables MPJ_HOME to C:\mpj and in PATH added value C:\mpj\bin

I added mpi.jar, mpj.jar in Project Structure -> Libraries

enter image description here

and wrote simple helloworld mpi program:

import mpi.MPI;

public class Main {

    public static void main(String[] args) {
        MPI.Init(args);
        int me = MPI.COMM_WORLD.Rank();
        int size = MPI.COMM_WORLD.Size();
        System.out.println("Hello world from <"+me+"> of <"+size+">");
        MPI.Finalize();
    }
}

I created run configuration described on picture: enter image description here

But I get the following error:

MPJ Express (0.44) is started in the multicore configuration
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at runtime.starter.MulticoreStarter$1.run(MulticoreStarter.java:281)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: 0
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)
    ... 6 more

I found similar problems in eclipse posted but none solution worked:

java.io.FileNotFoundException: null\conf\wrapper.conf (The system cannot find the path specified)

"Unresolved compilation problems" from running MPJ express in Eclipse Indigo

In Eclipse everything works fine but I need Intellij IDEA!

PS: (if you need javadoc add whole C:\mpj\lib folder and C:\mpj\src folder for library sources)

Olivann answered 1/4, 2016 at 12:30 Comment(0)
P
8

You need to change the main class to

"runtime.starter.MPJRun"

and VM options to include your main class

"-jar $MPJ_HOME$\lib\starter.jar nz.geek.colin.mpj.Main -np 4"

This is because MPJExpress runs and then loads your program in order to create multiple processes.

If IntelliJ complains about runtime.starter.MPJRun not found you can ignore it but if the warning bothers you you can add the starter.jar to the project.

Philippi answered 1/4, 2016 at 20:2 Comment(1)
It worked just with adding class name to VM options "-jar $MPJ_HOME$\lib\starter.jar Main -np 4"Olivann

© 2022 - 2024 — McMap. All rights reserved.