简体   繁体   English

如何在启动时将我的java应用程序(如.exe)传递给文档的路径?

[英]How can pass my java application (as .exe) the path of a document on startup?

I use JSmooth to turn my java application (jar) into an executable. 我使用JSmooth将我的java应用程序(jar)变成可执行文件。 It´sa simple text editor, like notepad. 这是一个简单的文本编辑器,如记事本。 I want to use the "Open With" function of windows to open certain files with the exe. 我想使用windows的“打开方式”功能用exe打开某些文件。 For this, I only need the path of each file. 为此,我只需要每个文件的路径。 How do I do this? 我该怎么做呢?

I thought about using a java-property and calling it with System.getProperty("VariableName"), though I don´t know if this is possible. 我想过使用java-property并用System.getProperty(“VariableName”)调用它,虽然我不知道这是否可行。 ${EXECUTABLEPATH} just gets me the location of the MyApp.exe. $ {EXECUTABLEPATH}只是让我获得MyApp.exe的位置。

For short properties may use Preferences.userNodeForPackage(MyExample.class); 对于简短属性,可以使用Preferences.userNodeForPackage(MyExample.class); and methods: get, put, flush. 和方法:get,put,flush。
https://docs.oracle.com/javase/8/docs/technotes/guides/preferences/index.html https://docs.oracle.com/javase/8/docs/technotes/guides/preferences/index.html

and/or to use properties file near your exe file for save paths https://docs.oracle.com/javase/7/docs/api/java/util/Properties.html 和/或使用exe文件附近的属性文件来保存路径https://docs.oracle.com/javase/7/docs/api/java/util/Properties.html

For open with Windows may use this schema for example: 对于Windows打开,可以使用此架构,例如:

if (Desktop.isDesktopSupported()) {
    Desktop desktop = Desktop.getDesktop();
    if (desktop.isSupported(Desktop.Action.OPEN)) {
         desktop.open(file);
    }
}

https://docs.oracle.com/javase/7/docs/api/java/awt/Desktop.html https://docs.oracle.com/javase/7/docs/api/java/awt/Desktop.html

For set associations see: https://www.thewindowsclub.com/change-file-associations-windows may be usefull Have the ability to set Java application as default file opener? 对于集合关联,请参阅: https//www.thewindowsclub.com/change-file-associations-windows可能有用l能否将Java应用程序设置为默认文件打开器?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将参数传递给打包的 java 应用程序 (.exe) - How to pass parameters to a packaged java application (.exe) 如何创建一个.exe安装程序来安装Java应用程序的.exe版本? - How can I create an .exe installer that installs an .exe version of my Java application? 如何获取Java Web应用程序中正在运行的.exe的绝对路径? - How can I get the absolute path of a running .exe in java web application? 如何在32位和64位系统上运行exe Java应用程序? - How can i run my exe Java application on both 32-bit and 64-bit systems? 如何将链接到SQL Server的Java应用程序导出到exe文件? - How to export my java application that is linked to sql server to an exe file? 我可以从Java应用程序中设计和打印报告/文档吗? - Can I design and print report/Document from my java Application JAVA:SWING:如何为Swing应用程序构建.exe - JAVA : SWING : How can i build a .exe for Swing application 如何在包装为.exe的Java应用程序上运行分析? - How can you run profiling on a Java application wrapped as an .exe? 如何在Opencmis Java中获取文档的路径 - How can I get the path of a document in opencmis java 如何将数据从.Net Web应用程序传递到Java Applet - How can I pass data from a .Net Web Application to my Java Applet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM