【发布时间】:2016-05-30 11:01:09
【问题描述】:
我按照this 问题中的步骤使用 Intellij 导出了一个 Java 项目,并在%PROJECT_ROOT%/out/artifacts/ContactRetriever.jar 中获得了一个 .jar 文件。
但是,当从命令行运行 .jar 文件时,
java -jar ContactRetriever.jar
给出以下输出:
Xalan-J command line Process class options:
-Common Options-
[-XSLTC (use XSLTC for transformation)]
[-IN inputXMLURL]
[-XSL XSLTransformationURL]
[-OUT outputFileName]
[-E (Do not expand entity refs)]
[-EDUMP {optional filename} (Do stackdump on error.)]
[-XML (Use XML formatter and add XML header.)]
[-TEXT (Use simple Text formatter.)]
[-HTML (Use HTML formatter.)]
[-PARAM name expression (Set a stylesheet parameter)]
[-MEDIA mediaType (use media attribute to find stylesheet associated with a d
ocument.)]
[-FLAVOR flavorName (Explicitly use s2s=SAX or d2d=DOM to do transform.)]
[-DIAG (Print overall milliseconds transform took.)]
[-URIRESOLVER full class name (URIResolver to be used to resolve URIs)]
[-ENTITYRESOLVER full class name (EntityResolver to be used to resolve entiti
es)]
(press <return> to continue)
我的项目的清单文件 (MANIFEST.MF) 包含:
Manifest-Version: 1.0
Main-Class: Main
Main 是主类(入口点)。
项目的布局是:
项目结构工件是:
和模块:
为什么 main 没有被执行?
编辑:
main中的代码是:
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.*;
import com.gargoylesoftware.htmlunit.util.Cookie;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
import java.util.logging.Level;
public class Main extends Defaults{
private static WebClient webClient;
public static void main(String[] args) {
if(args.length == 0) {
printUsage();
return;
}
if(args[1] == null)
initAccounts("");
else
initAccounts(args[2]);
if(args[4] == null || args[6] == null)
printUsage();
else
getContacts(args[4], args[6], 4);
// initAccounts("");
// getContacts("C:\\Users\\user\\Downloads", "C:\\Users\\user\\Projects\\ContactRetriever", 4);
}
}
【问题讨论】:
-
你的主班到底在哪里?通常,您必须在清单中提供类的完整路径,例如 org.yourapp.Main
-
Main.class。它不是已经包含在 .jar 中了吗?
-
我的意思是,你的主类是在包中还是在根目录中,就在
src/Main之下? -
在root下,main路径:root --> src --> main --> java --> Main.java
-
我看到您使用的是 maven,您是否使用
mvn clean package命令打包您的应用程序?
标签: java android intellij-idea jar export