简体   繁体   English

如何创建指向jar文件的可执行链接?

[英]How to create an executable link to jar file?

I'm developing a Java GUI-less application and I need to test its behavior running multiple instances of it at the same time. 我正在开发一个无Java GUI的应用程序,我需要同时运行多个实例来测试其行为。

I created this folder structure 我创建了这个文件夹结构

Testing
  ├──> Instance1
  │      ├──> App.jar
  │      └──> cfg.properties
  ├──> Instance2
  │      ├──> App.jar
  │      └──> cfg.properties
  ├──> Instance3
  │      ├──> App.jar
  │      └──> cfg.properties
  └──> Instance4
         ├──> App.jar
         └──> cfg.properties

The cfg.properties file is different for each folder, but the App.jar files are just copies of the .jar generated by the IDE. 每个文件夹的cfg.properties文件不同,但是App.jar文件只是IDE生成的.jar的副本。 The problem with this is I need to manually replace each .jar, each time I make any change to the original. 问题是每次我对原始文件进行任何更改时,我都需要手动替换每个.jar。

Is there any way to have something like a link to the original .jar file instead of real copies of it, so all of them auto update each time I change the original one? 有没有办法像链接到原始.jar文件一样代替它的真实副本,因此每当我更改原始文件时它们都会自动更新? (A solution in Windows would be great, but any Linux trick would also work for me) (Windows中的解决方案很棒,但是任何Linux技巧也对我有用)

you can move App.jar into new folder and specify app.jar path in classpath java argument 您可以将App.jar移到新文件夹中,并在classpath java参数中指定app.jar路径

Testing
  ├──> Jar
  │      ├──> App.jar
  ├──> Instance1
  │      └──> cfg.properties
  ├──> Instance2
  │      └──> cfg.properties
  ├──> Instance3
  │      └──> cfg.properties
  └──> Instance4
         └──> cfg.properties

Test instance 1 测试实例1

    cd  Testing/Instance1
    java -jar -cp ../Jar/App.jar 

in this way you don't need a jar in each instance folder 这样,您无需在每个实例文件夹中添加一个jar

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM