gpt4 book ai didi

java - 为什么这个 Java jar 不起作用?

转载 作者:行者123 更新时间:2023-12-01 15:37:12 30 4
gpt4 key购买 nike

当我运行下面的代码时,出现以下错误。

C:\Documents and Settings\BOS\Desktop\test>java -jar test.jar
Exception in thread "main" java.lang.NullPointerException
at sun.launcher.LauncherHelper.getMainClassFromJar(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

我在\test 目录中有这些文件 = crimson.jar robosuite-api.jar 和 test.jar。

这是他们给出的启动机器人的例子?

import com.kapowtech.robosuite.api.java.rql.*;
public class SimpleRunRobot {
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: RunRobot <robotURL>");
System.exit(1);
}
try {
// Run the robot
RQLResult result =
RobotExecutor.getRobotExecutor().execute(args[0]);
// Output the results
System.out.println(result);
}
catch (RQLException e) {
System.out.println("An error occurred: " + e);
}
}
}

为什么这会给我未知来源错误?

 package robosuite.robots;

import com.kapowtech.robosuite.api.java.rql.RQLException;
import com.kapowtech.robosuite.api.java.rql.RQLResult;
import com.kapowtech.robosuite.api.java.rql.RobotExecutor;
import com.kapowtech.robosuite.api.java.rql.construct.RQLObjects;


import java.io.IOException;
import java.util.ArrayList;
import java.util.List;



/**
*
* <p>
* This is an autogenerated class. It has been generated from the
* <code>library:/test.robot</code> file.
*
* @author RoboSuite
*/
public class Test {

// ----------------------------------------------------------------------
// Class fields
// ----------------------------------------------------------------------

private static final String ROBOT_URL = "library:/test.robot";
private static final RobotExecutor ROBOT_EXECUTOR = RobotExecutor.getRobotExecutor(SingletonRQLEngine.getInstance());
private static final Converter CONVERTER = Converter.getInstance();



// ----------------------------------------------------------------------
// Constructors
// ----------------------------------------------------------------------

/**
* Creates a new Test instance that can be used to execute the
* <code>library:/test.robot</code>.
*/
public Test() {
}

// ----------------------------------------------------------------------
// Instance methods
// ----------------------------------------------------------------------

/**
* Executes this robot.
*
* @param test an input object to the robot.
* @return an array of output objects.
* @throws java.io.IOException if the execution fails for some reason.
*/
public Testst[] run(Test0 test) throws java.io.IOException {
try {
// Prepare input objects
List parameters = new ArrayList();
parameters.add(test);

RQLObjects inputObjects = CONVERTER.convertBeansToRQLObjects(parameters);

// Run robot
RQLResult rqlResult = ROBOT_EXECUTOR.execute(ROBOT_URL, inputObjects);

// Extract output objects
RQLObjects outputObjects = rqlResult.getOutputObjects();
List result = CONVERTER.convertRQLObjectsToBeans(outputObjects);
return (Testst[]) result.toArray(new Testst[result.size()]);
} catch (RQLException e) {
throw new IOException(e.toString());
}
}


/* ------------------------------------------------------------------- */
}

最佳答案

如果您使用 Java 7,请阅读本文。

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7067922

关于java - 为什么这个 Java jar 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8697347/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com