, जावा में निम्न कोड दिया यू त्रुटियों की एक बहुत कुछ है:त्रुटि: पैकेज com.google.common.base मौजूद नहीं है जब यह संकलन
Main.java:1: error: package com.google.common.base does not exist import com.google.common.base.Preconditions; ^
Main.java:2: error: package com.google.common.collect does not exist import com.google.common.collect.Lists; ^
Main.java:3: error: package org.ros.exception does not exist import org.ros.exception.RosRuntimeException; ^
Main.java:4: error: package org.ros.internal.loader does not exist import org.ros.internal.loader.CommandLineLoader; ^
Main.java:5: error: package org.ros.node does not exist import org.ros.node.DefaultNodeMainExecutor; ^
Main.java:6: error: package org.ros.node does not exist import org.ros.node.NodeConfiguration; ^
Main.java:7: error: package org.ros.node does not exist import org.ros.node.NodeMainExecutor;
मैं इसे इंटेलीजे के माध्यम से चलाते हैं। क्या किसी को पता है कि यह क्यों काम नहीं करता है?
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import org.ros.exception.RosRuntimeException;
import org.ros.internal.loader.CommandLineLoader;
import org.ros.node.DefaultNodeMainExecutor;
import org.ros.node.NodeConfiguration;
import org.ros.node.NodeMainExecutor;
// This class will run a publisher and subscriber, and relay data between them.
public class Main {
static private Talker pubNodeMain;
static private Listener subNodeMain;
public static void main(String[] argv) throws Exception {
// Set up the executor for both of the nodes
NodeMainExecutor nodeMainExecutor = DefaultNodeMainExecutor.newDefault();
// Load the publisher
String[] pubArgv = {"Talker"};
CommandLineLoader pubLoader = new CommandLineLoader(Lists.newArrayList(pubArgv));
String nodeClassName = pubLoader.getNodeClassName();
System.out.println("Loading node class: " + pubLoader.getNodeClassName());
NodeConfiguration pubNodeConfiguration = pubLoader.build();
try {
pubNodeMain = (Talker) pubLoader.loadClass(nodeClassName);
} catch (ClassNotFoundException e) {
throw new RosRuntimeException("Unable to locate node: " + nodeClassName, e);
} catch (InstantiationException e) {
throw new RosRuntimeException("Unable to instantiate node: " + nodeClassName, e);
} catch (IllegalAccessException e) {
throw new RosRuntimeException("Unable to instantiate node: " + nodeClassName, e);
}
Preconditions.checkState(pubNodeMain != null);
nodeMainExecutor.execute(pubNodeMain, pubNodeConfiguration);
// Load the subscriber
String[] subArgv = {"Listener"};
CommandLineLoader subLoader = new CommandLineLoader(Lists.newArrayList(subArgv));
nodeClassName = subLoader.getNodeClassName();
System.out.println("Loading node class: " + subLoader.getNodeClassName());
NodeConfiguration subNodeConfiguration = subLoader.build();
try {
subNodeMain = (Listener) subLoader.loadClass(nodeClassName);
} catch (ClassNotFoundException e) {
throw new RosRuntimeException("Unable to locate node: " + nodeClassName, e);
} catch (InstantiationException e) {
throw new RosRuntimeException("Unable to instantiate node: " + nodeClassName, e);
} catch (IllegalAccessException e) {
throw new RosRuntimeException("Unable to instantiate node: " + nodeClassName, e);
}
Preconditions.checkState(subNodeMain != null);
nodeMainExecutor.execute(subNodeMain, subNodeConfiguration);
}
}
आप शायद उन पैकेज के तहत संकुल खुद को बजाय कक्षाओं आयात करने के लिए कोशिश की। उदाहरण के लिए, पहली त्रुटि के लिए 'आयात स्थिर com.google.com.base.Preconditions। *' जोड़ने का प्रयास करें। – chesh
मेवेन या ग्रेडल के लिए विज्ञापन निर्भरता, फिर 'ग्रेलेव्यू विचार' या 'मेवेन क्लीन बिल्ड' और इंटेलिज में फ़ाइल -> अमान्य कैहिस/पुनरारंभ करें –