我想用我的maven项目得到一个工作的jar文件.
构建部分是:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.14</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>6.4.1</version>
</dependency>
</dependencies>
<configuration>
<consoleOutput>true</consoleOutput>
<configLocation>${basedir}/src/test/resources/checkstyle_swt1.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptor>src/assembly/src.xml</descriptor>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
<addClasspath>true</addClasspath>
<mainClass>org.jis.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Run Code Online (Sandbox Code Playgroud)
所以我现在的问题是我不知道如何将mainclass正确地实现到我的pom.xml中以及稍后我的jar文件中.文件夹结构是:src/main/java/org/jis/Main.java但是如果我添加以下行
<mainClass>src.main.java.org.jis.Main</mainClass>
Run Code Online (Sandbox Code Playgroud)
它不起作用.
提前致谢
第一:我意识到这个问题应该很简单,很多人似乎都经历过这个问题.但是,看来我的问题可能与现有帖子略有不同.
我正在使用NetBeans来编译Java应用程序.完成构建后,输出会正确进入dist \文件夹.那里有jar文件.如果我转到命令行,请导航到该文件夹,然后调用以下命令:
java -jar Prosperity.jar
一切正常.显然,应用程序的名称是Prosperity.以下命令也可以正常工作:
javaw -jar Prosperity.jar
但是,双击.jar文件会显示消息:"找不到主类:",然后提供.jar文件的路径.我已经检查过一百次.jar文件中存在META-INF文件夹,并且其中存在一个具有正确主类名称的MANIFEST.MF.我还检查了.jar文件中是否存在主类(App.class).class文件.
所以问题是:双击文件和运行javaw之间的区别是什么?它真的令人沮丧,它不会只是运行!
谢谢你可以给我的任何方向,我是tearin'我的头发在这里!
我有一个非常简单的代码:
package mygame;
public class RunGame {
public static void main(String[] args) {
System.out.println(args[0]);
}
}
Run Code Online (Sandbox Code Playgroud)
我可以编译该代码,但我无法运行它.当我在命令行中输入"java RunGame"时,我得到:
线程"main"中的异常java.lang.NoClassDefFoundError:RunGame(错误的名称:mygame/RunGame).
....
找不到主类:RunGame.程序将会退出.
我有一个客户服务器应用程序.服务器由带有jersey的restful服务组成,并部署在tomcat 7上.实际上,我需要在客户端访问服务之前创建服务的上下文(读取一些高大小的文件).是否可以创建我的webapp的主类?
例:
class MainClass {
public doIt() {
...
else doIt();
}
}
class SubClass extends MainClass {
@Override
public doIt() {
super.doIt();
...
}
}
Run Code Online (Sandbox Code Playgroud)
现在的问题是:
这是非常奇怪的行为,编程问题!我试图用this.doIt()调用递归,但这没有帮助.有人有想法吗?
非常感谢您的回答,这个问题已经解决了.
所以我是新手使用Doxygen,我能够让它顺利运作.我能够记录我的类和结构,并完美地生成HTML文件.我遇到的问题是它不会解析我的main.cpp文件.所有的类和结构都有自己的.h和.cpp文件,它们处理得很好.如何让Doxygen为main.cpp制作文档?它没有.h文件,因为这是程序开始和结束的地方.我甚至都不知道要把什么放在主文件的.h文件中.我在Windows中使用Doxywizard.
编辑:
我把它放在main中,它会生成一个主页面:
/**
@mainpage
This is a test application.
@author Alex
@date 10/21/2010
@version 1.0
*/
Run Code Online (Sandbox Code Playgroud)
但是在函数原型的文件中,我有这个并且它没有被解析:
/**
@brief Error handler for the PDF writer.
It does nothing. It just has to exist.
*/
void error_handler (HPDF_STATUS error_no,
HPDF_STATUS detail_no,
void *user_data)
{
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个简单的jdbc数据库调用应用程序.我在buildpath中有jar并且我的sqljdbc_Auth.dll在文件夹中:
C:\ Program Files(x86)\ jdbc\sqljdbc_4.0\enu\auth\x64
我收到此错误消息
错误:无法找到或加载主类文件
我的VM参数:看起来像这样......
-Djava.library.path = C:\ Program Files(x86)\ jdbc\sqljdbc_4.0\enu\auth\x64
这就是我目前所知道的.是否加载sqljdbc_auth.dll文件java.library.path比参与更多?
我已经将一个java项目编译成一个Jar文件,并且在运行它时遇到了问题.
当我跑:
java -jar myJar.jar
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
Could not find the main class: myClass
Run Code Online (Sandbox Code Playgroud)
类文件不在jar的根目录中,所以我尝试更改主类的路径以匹配类文件的路径,我得到了同样的问题.
我应该扁平化文件结构吗?如果是这样我该怎么做 如果有任何用途,我正在使用Ant来构建Jar文件.
UPDATE
这是jar的内容和相关的Ant部分,我已经将我工作的公司名称改为"org":
META-INF/
META-INF/MANIFEST.MF
dataAccessLayer/
dataAccessLayer/databaseTest.class
org/
org/eventService/
org/eventService/DatabaseObject.class
org/eventService/DatabaseObjectFactory.class
org/eventService/DbEventClientImpl$HearBeatMonitor.class
org/eventService/DbEventClientImpl.class
org/eventService/EmptyQueryListException.class
org/eventService/EventHandlerWorkItem.class
org/eventService/EventProcessor.class
org/eventService/EventTypeEnum.class
org/eventService/EventWorkQueue$MonitorThread.class
org/eventService/EventWorkQueue$PoolWorker.class
org/eventService/EventWorkQueue.class
org/eventService/FailedToLoadDriverException.class
org/eventService/IConnectionFailureListener.class
org/eventService/InvalidEventTypeException.class
org/eventService/JdbcInterfaceConnection.class
org/eventService/NullArgumentException.class
org/eventService/OracleDatabaseObject.class
org/eventService/ProactiveClientEventLogger.class
org/eventService/ProactiveClientEventLoggerException.class
org/eventService/PropertyMap.class
org/eventService/SQLServerDatabaseObject.class
org/eventService/TestHarness.class
org/eventService/Utilities.class
Run Code Online (Sandbox Code Playgroud)
而蚂蚁目标:
<target name="compile" depends="init" description="compile the source ">
<javac srcdir="src" destdir="bin" classpathref="project.class.path"/>
</target>
<target name="buildjar" description="build jar file" depends="compile">
<mkdir dir="dist"/>
<jar destfile="dist/myJar.jar" basedir="bin" includes="**/*.class" >
<manifest>
<attribute name="Main-Class" value="org.eventService.ProactiveClientEventLogger"/>
</manifest>
</jar>
</target>
Run Code Online (Sandbox Code Playgroud) 我\xe2\x80\x99正在研究OOP,并且我\xe2\x80\x99已经得到了这篇论文。因为我知道从超类继承子类就像:class superClass : subClass{ }但我\xe2\x80\x99m 很好奇这是否是可接受的形式:class superClass : subClass1 : subclass2。
简而言之,我想从另一个类继承一个子类。因为如果我遇到一个问题,比如有一个子类,并且它是从超类继承的,因为它们具有公共数据,该怎么办?\n这样可以吗?
\n\n但这里有一个问题:如果我需要另一个子类,它与第一个子类和超类或主类都有共同的数据怎么办?
\n