- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
似乎无法弄清楚为什么当我运行由 launch4j 创建的 .exe 文件时,我的 JFileChooser
从未出现。很多人主要讨论这个错误的类路径,但我没有意识到解决方案。
错误1:
no main manifest attribute in C:\Users\Documents\...\HPLCData.exe
现在,如果我将类路径更改为 KFile.Main,则会收到此错误消息
错误2:
Error: Could not find or locate main class KFile.Main
错误3:
错误:无法找到或定位主类 KFile.class
诚然,我对java相当陌生,也许答案就在我面前或者是显而易见的,如果是这样,抱歉。否则,我读到的内容表明类路径存在问题,并且我不完全确定需要更改什么。
我想知道它是否与生成的 xml 文件中的部分有关,但我不知道那里会发生什么。我尝试过改变所有有点奇怪的事情,closest post我发现提到了一些关于使用完整类路径的内容。或者 jar 包装可能有问题,但我不这么认为,因为我仔细检查了 this
以下是由 launch4j 生成的用于包装 .exe 文件的 .xml 文件。
案例1:
<?xml version="1.0" encoding="UTF-8"?>
<launch4jConfig>
<dontWrapJar>false</dontWrapJar>
<headerType>console</headerType>
<jar>C:\Users\red\Documents\Java Modules\Introductory Files\HPLCData.jar</jar>
<outfile>C:\Users\red\Documents\Java Modules\Introductory Files\HPLCData.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
<chdir>.</chdir>
<priority>normal</priority>
<downloadUrl>http://java.com/download</downloadUrl>
<supportUrl></supportUrl>
<stayAlive>false</stayAlive>
<restartOnCrash>false</restartOnCrash>
<manifest></manifest>
<icon></icon>
<jre>
<path>C:\Users\red\Documents\Java Modules\Introductory Files\</path>
<bundledJre64Bit>false</bundledJre64Bit>
<bundledJreAsFallback>false</bundledJreAsFallback>
<minVersion>1.6.0_1</minVersion>
<maxVersion></maxVersion>
<jdkPreference>preferJre</jdkPreference>
<runtimeBits>64/32</runtimeBits>
</jre>
<versionInfo>
<fileVersion>1.0.0.0</fileVersion>
<txtFileVersion>version 1</txtFileVersion>
<fileDescription>Manage HPLC Data</fileDescription>
<copyright>Kemin 2016</copyright>
<productVersion>1.0.0.0</productVersion>
<txtProductVersion>version 1</txtProductVersion>
<productName>HPLC Data</productName>
<companyName>Red</companyName>
<internalName>Red</internalName>
<originalFilename>HPLCData.exe</originalFilename>
</versionInfo>
</launch4jConfig>
案例2:
<?xml version="1.0" encoding="UTF-8"?>
<launch4jConfig>
<dontWrapJar>false</dontWrapJar>
<headerType>console</headerType>
<jar>C:\Users\red\Documents\Java Modules\Introductory Files\HPLCData.jar</jar>
<outfile>C:\Users\red\Documents\Java Modules\Introductory Files\HPLCData.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
<chdir>.</chdir>
<priority>normal</priority>
<downloadUrl>http://java.com/download</downloadUrl>
<supportUrl></supportUrl>
<stayAlive>false</stayAlive>
<restartOnCrash>false</restartOnCrash>
<manifest></manifest>
<icon></icon>
<classPath>
<mainClass>KFile.Main</mainClass>
</classPath>
<jre>
<path>C:\Users\red\Documents\Java Modules\Introductory Files\</path>
<bundledJre64Bit>false</bundledJre64Bit>
<bundledJreAsFallback>false</bundledJreAsFallback>
<minVersion>1.6.0_1</minVersion>
<maxVersion></maxVersion>
<jdkPreference>preferJre</jdkPreference>
<runtimeBits>64/32</runtimeBits>
</jre>
<versionInfo>
<fileVersion>1.0.0.0</fileVersion>
<txtFileVersion>version 1</txtFileVersion>
<fileDescription>Manage HPLC Data</fileDescription>
<copyright>Kemin 2016</copyright>
<productVersion>1.0.0.0</productVersion>
<txtProductVersion>version 1</txtProductVersion>
<productName>HPLC Data</productName>
<companyName>Red</companyName>
<internalName>Red</internalName>
<originalFilename>HPLCData.exe</originalFilename>
</versionInfo>
</launch4jConfig>
案例3:
<manifest></manifest>
<icon></icon>
<classPath>
<mainClass>KFile.class</mainClass>
</classPath>
Java代码:
import java.io.*;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.FileVisitResult;
import java.nio.MappedByteBuffer;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import java.util.Collection;
import java.util.ArrayList;
import java.nio.file.SimpleFileVisitor;
public class KFile extends SimpleFileVisitor<Path> {
public static void main(String[] args) {
Path currPath = Paths.get("");
String currDir = currPath.toAbsolutePath().toString();
System.out.println(currDir);
File dataDir = chooseDir("open");
File destDir = chooseDir("save");
if(!destDir.exists()) {
try {
destDir.mkdir();
}
catch (SecurityException se) {
System.out.println("Couldn't make directory!");
}
}
int n = 0;
if(dataDir.exists()) {
Collection<Path> allDir = new ArrayList<Path>();
try {
addTree(dataDir.toPath(),allDir);
}
catch (IOException e) {
System.out.println("Error with scanning");
}
for( Path thisPath : allDir ) {
if(thisPath.toString().contains("Report.pdf")) {
Path thisDir = thisPath.getParent();
File f = new File(thisDir.toString(), "\\Report.txt");
n = n + 1;
String fileName = "Report " + n + ".pdf";
try {
fileName = parseName(f);
System.out.println(fileName);
} catch (IOException e) {
e.printStackTrace();
}
File thisFile = new File(destDir + "\\" + fileName);
try {
copyFile(thisPath.toFile(),thisFile);
} catch ( IOException e) {
e.printStackTrace();
}
}
}
}
}
public static boolean copyFile(File sourceFile, File destFile) throws IOException {
//create file if it doesn't exist.
if(!destFile.exists()) {
destFile.createNewFile();
}
FileChannel source = null;
FileChannel destination = null;
try {
source = new FileInputStream(sourceFile).getChannel();
destination = new FileOutputStream(destFile).getChannel();
destination.transferFrom(source, 0, source.size());
}
finally {
if(source != null) {
source.close();
}
if(destination != null) {
destination.close();
return true;
}
return false;
}
}
public static File chooseDir(String s) {
JFrame myFrame = new JFrame("HPLC Data Transfer");
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myFrame.pack();
myFrame.setVisible(true);
JFileChooser chooser = new JFileChooser();
File currDir = new File(System.getProperty("user.home") + "\\Documents");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setCurrentDirectory(currDir);
int choice = 0;
if (s.equals("save")) {
choice = chooser.showSaveDialog(myFrame);
} else {
choice = chooser.showOpenDialog(myFrame);
}
myFrame.setVisible(false);
myFrame.removeAll();
myFrame.dispose();
if(choice == JFileChooser.APPROVE_OPTION) {
System.out.println("You chose to open: " + chooser.getSelectedFile().getName());
return chooser.getSelectedFile();
}
return new File("");
}
static String parseName(File f) throws IOException {
BufferedReader textReader = new BufferedReader(new InputStreamReader(new FileInputStream(f), "UTF-16"));
int lnCnt = 32;
String[] fileData = new String[lnCnt];
for (int i = 0; i < lnCnt; i++) {
fileData[i] = textReader.readLine();
}
String name = fileData[1].substring(13) + ".pdf";
textReader.close();
return name;
}
static void addTree(Path directory, final Collection<Path> all)
throws IOException {
Files.walkFileTree(directory, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
throws IOException {
all.add(file);
return FileVisitResult.CONTINUE;
}
});
}
}
最佳答案
如消息所示,Launch4J 似乎调用配置中指定为 mainClass
的任何类的 Main
方法。所以:
对于KFile.class
,您需要在package KFile
中有一个名为class
的类。这甚至是不可能的,因为你不能有一个名为 class
的 class
;是保留字
对于KFile.Main
,您需要在package KFile
中有一个名为Main
的类。
您没有包声明,您的类KFile
位于默认包中。所以你需要的声明是
<mainClass>KFile</mainClass>
关于java - Launch4j 将 jar 转为 exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34728157/
运行真机调试时,出现如下问题。 Could not launch “MY-APP-NAME” iPhone has denied the launch request. Internal launch
每次单击“运行方式”按钮时,都会收到以下消息。 “选品无法推出,近期也没有推出。” 如果我选择“运行方式”按钮附近的下拉箭头,然后选择“新配置”选项(这是我设置为使用本地主机启动的配置)......它
启动过去有效的python文件时出现上述错误。我想我知道这是怎么发生的,但不确定如何解决。我有两台计算机双启动不同的操作系统,并使用保管箱保持它们之间的同步。过去,我以这种方式将我的Eclipse工作
我尝试使用 Eclipse 构建并运行“Hello world”,但它无法运行。我不使用 Android 或其他任何纯 C++。 http://i57.tinypic.com/x51h5h.png 最
这个问题在这里已经有了答案: "Selection cannot be launched and there are no recent launches” when Eclipse for Andr
在 Kotlin 中有多种启动协程的方法。我发现了几个示例,其中 GlobalScope 和 CoroutineScope 被使用。但是后者是在启动协程时直接创建的: 使用 GlobalScope :
我正在使用 10gen 版本在 OS X 上安装 MongoDB。 但是their installation tutorial事实证明对我来说有点稀缺。 到目前为止,我已经找到了安装为 launch
我在互联网上到处寻找,并尝试了论坛所说的一切,但没有任何效果。这个错误不断出现。我试过运行我的java项目(不适用于android),即使下拉运行按钮不起作用,因为它说“不适用”。 最佳答案 Ecli
我理解 std::async 对以下参数的作用。 std::launch::async std::launch::deferred 然而,std::launch::async | 会发生什么? std
我正在尝试使用 Eclipse 打开一个解压缩的 Android 项目,但每次我尝试运行或调试时都会显示此错误:“无法启动选择并且最近没有启动”。 所以我查找并尝试从现有源创建一个新项目,但打开时出现
我删除了 React Native 创建的默认启动屏幕文件,而是创建了一个启动图像。当我在模拟器中运行应用程序时,会显示启动图像,但是当我存档项目并通过 Testflight 打开它时,它仍然显示旧的
从深层链接(具有应用特定方案的 URL)启动我的 iOS 应用时,我在日志中收到此错误: lsd[738] : LaunchServices: application launch failed -
当我使用 visual studio code 调试 nodejs 应用程序时。visual studio code 告诉我 request 'launch': cannot launch targe
我创建了 Cocoa 应用程序,它是启动代理的类型。为了分发这个,我还创建了一个包,它安装该应用程序并将 launchagnet plist 文件复制到/Libraries/LaunchAgents
大家好,我今天在开发的 Java Swing 应用程序中发现了一个很大的疑问。 我发现的问题是launch() 当我在本地尝试我开发的应用程序时,它运行时没有任何延迟,但是当我使用 jnlp 从我的
我正在尝试使用 JavaFX 设置视频在 JFrame 中播放。 但是一旦我调用 launch() 函数来设置 JavaFX 并播放视频,我就会收到以下错误 应用程序构造函数中出现异常线程“AWT-E
我试图在 Android Studio 的外部工具中设置 javah 命令,但我得到了 IllegalArgumentException: Not a valid class name: Files\
我正在尝试创建一个简单的应用程序。我创建了一个新的 AVD。我启动了它。等了一个小时,模拟器只显示ANDROID。我卡住了。有人可以帮忙吗。 一个小时的样子请不要标记重复。我尽可能多地搜索和尝试。 我
进程文件: launch or launch.exe 进程名称: Vantarakis Launchh 进程类别:存在安全风险的进程 英文描述: launch.exe is a part o
将 google chrome 更新到最新版本 89.0.4389.82 (Official Build) (64-bit) 后开始出现错误。操作系统:Windows 10 错误: Puppeteer
我是一名优秀的程序员,十分优秀!