我下载了mpj-v0_44并将其解压缩到C:\mpj把Windows系统环境。变量MPJ_HOMEC:\mpj,并在PATH中添加了值C:\mpj\bin我在项目结构->库中添加了mpi.jarmpj.jar java - 在Intellij IDEA中运行的MPJ Express(Java MPI)-LMLPHP
并编写了简单的helloworld mpi程序:

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();
    }
}
我创建了图片中描述的运行配置:
java - 在Intellij IDEA中运行的MPJ Express(Java MPI)-LMLPHP
但我收到以下错误:
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
我在发布的Eclipse中发现了类似的问题,但是没有解决方案:
java.io.FileNotFoundException: null\conf\wrapper.conf (The system cannot find the path specified)
"Unresolved compilation problems" from running MPJ express in Eclipse Indigo
在Eclipse中一切正常,但是我需要Intellij IDEA!
PS:
(如果需要javadoc,请为库源添加整个C:\mpj\lib文件夹和C:\mpj\src文件夹)

最佳答案

您需要将主类更改为

"runtime.starter.MPJRun"

和VM选项以包括您的主要类(class)
"-jar $MPJ_HOME$\lib\starter.jar nz.geek.colin.mpj.Main -np 4"

这是因为MPJExpress运行,然后加载您的程序以创建多个进程。

如果IntelliJ提示找不到runtime.starter.MPJRun,则可以忽略它,但是如果警告困扰您,可以将starter.jar添加到项目中。

09-11 21:58