How to set a long Java classpath in Windows?

后端 未结 12 1099
清酒与你
清酒与你 2020-11-27 15:18

I\'m trying to run a particular JUnit test by hand on a Windows XP command line, which has an unusually high number of elements in the class path. I\'ve tried several varia

12条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 16:06

    The Windows command line is very limiting in this regard. A workaround is to create a "pathing jar". This is a jar containing only a Manifest.mf file, whose Class-Path specifies the disk paths of your long list of jars, etc. Now just add this pathing jar to your command line classpath. This is usually more convenient than packaging the actual resources together.

    As I recall, the disk paths can be relative to the pathing jar itself. So the Manifest.mf might look something like this:

    Class-Path: this.jar that.jar ../lib/other.jar
    

    If your pathing jar contains mainly foundational resources, then it won't change too frequently, but you will probably still want to generate it somewhere in your build. For example:

    
      
        
      
    
    

提交回复
热议问题