我有蝙蝠文件:
java -cp "./lib/*:." TestRunner
当我运行bat文件时,我有
Can not load main class TestRunner
在我得到命令之前:
java -cp .\lib\*;. TestRunner
和
java -cp .\lib\*;. com.pkg.TestRunner
同样的错误。
帮助我理解。我用maven编译了所有源代码,并且在目标文件夹target/src/java/main/com/pkg/TestRunner.class
中进行了所有文件,所有文件都没有在刚编译的jar中编写,我想从编译文件集中运行文件
也许maven不知何故没有指定主类,
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.pkg</groupId>
<artifactId>automation</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<build>
<directory>target</directory>
<outputDirectory>target/classes</outputDirectory>
<finalName>AUTOMATION-01</finalName>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
</build>
<reporting>
<outputDirectory>target/site</outputDirectory>
</reporting>
<profiles>
<profile>
<id>release-profile</id>
<activation>
<property>
<name>performRelease</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<updateReleaseInfo>true</updateReleaseInfo>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.2.11</version>
</dependency>
</dependencies>
</project>
我的树:
\---target
+---classes
| +---com
| | +---example
| | | \---ru
| | | \---pkg
| | | \---webservices
| | | +---submission
| | | | \---submissionapi
| | | \---synchronisation
| | | \---syncsfdataapi
| | +---module
| | | +---ac
| | | | \---ws
| | | | \---tt
| | | | \---webservice
| | | | \---pc
| | | | \---quoting
| | | | \---quotingapi
| | | \---ws
| | | \---soapheaders
| | \---pkg
| | +---comparation
| | +---filters
| | +---model
| | +---runner
| | +---utils
| | \---ws
| \---data_request
| +---request
| \---responce
\---maven-status
\---maven-compiler-plugin
\---compile
\---default-compile
答案 0 :(得分:1)
您是否在没有:.
的情况下进行了尝试,因为这看起来像bash syntax,这意味着如果.\lib\*
不存在则使用当前目录.
如果你在Windows上,我建议删除:.
并尝试其中一种变体
java -cp "./lib/*" TestRunner
java -cp ".\\lib\\*" TestRunner
java -cp "lib\*" TestRunner
所有这些都使用相对路径。如果它失败了你应该尝试使用完整路径:
java -cp "c:/some/folder/lib" TestRunner
java -cp "c:\\some\\folder\\lib" TestRunner
<强>更新强>
尝试将此示例转换为抓取here
D:\myprogram\
|
---> org\
|
---> mypackage\
|
---> HelloWorld.class
---> SupportClass.class
---> UtilClass.class
java -classpath D:\myprogram org.mypackage.HelloWorld
答案 1 :(得分:0)
很简单。添加到maven pom.xml说明,将有关主类和所需库的信息放入MANIFEST.MF:
IObservable<TimeInterval<long>> observable = Observable.Interval(TimeSpan.FromMilliseconds(750)).TimeInterval();
using (observable.Subscribe(
x => Console.WriteLine("{0}: {1}", x.Value, x.Interval)))
{
Console.WriteLine("Press any key to unsubscribe");
Console.ReadKey();
}
执行包后,您可以使用命令
启动应用程序 <plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.pkg.TestRunner</mainClass>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
其中project - 项目名称。
答案 2 :(得分:0)
由于TestRunner位于'use strict';
var React = require('react-native');
var {
StyleSheet,
Text,
TouchableOpacity,
View,
AppRegistry,
NavigatorIOS
} = React;
var MainApp = React.createClass({
render: function() {
return (
<NavigatorIOS
style={styles.mainContainer}
initialRoute={{
component: FirstScreen,
title: 'First Screen',
passProps: { text: ' ...' },
}}
/>
);
},
});
var FirstScreen = React.createClass({
render: function() {
return (
<View style={styles.container}>
<Text style={styles.helloText}>
Hello {this.props.text}
</Text>
<TouchableOpacity
style={styles.changeButton} onPress={this.gotoSecondScreen}>
<Text>Click to change</Text>
</TouchableOpacity>
</View>
);
},
gotoSecondScreen: function() {
console.log("button pressed");
this.props.navigator.push({
title: "Second Screen",
component: SecondScreen
});
},
});
var SecondScreen = React.createClass({
render: function() {
return (
<View style={styles.container}>
<Text style={styles.helloText}>
Select a greeting
</Text>
<TouchableOpacity
style={styles.changeButton} onPress={() => this.sayHello("World!")}>
<Text>...World!</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.changeButton} onPress={() => this.sayHello("my Friend!")}>
<Text>...my Friend!</Text>
</TouchableOpacity>
</View>
);
},
sayHello: function(greeting) {
console.log("world button pressed");
this.props.navigator.replacePreviousAndPop({
title: "First Screen",
component: FirstScreen,
passProps: {text: greeting}
});
}
});
var styles = StyleSheet.create({
mainContainer: {
flex: 1,
backgroundColor: "#eee"
},
container: {
flex: 1,
alignItems: "center",
justifyContent: "center",
marginTop: 50,
},
helloText: {
fontSize: 16,
},
changeButton: {
padding: 5,
borderWidth: 1,
borderColor: "blue",
borderRadius: 4,
marginTop: 20
}
});
AppRegistry.registerComponent("TestApp", () => MainApp);
包中,因此首先尝试使用以下命令运行它:
com.pkg.runner
注意,当您运行java -classpath . com.pkg.runner.TestRunner
命令时,您必须是java
文件夹中的一个以上。
在这里写下结果