Linux中的类路径限制 [英] Classpath limitation in Linux

查看:38
本文介绍了Linux中的类路径限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在从Shell脚本执行独立的Java程序,并使用一个comman脚本来提及类路径,路径等.在此常见脚本中,我们现在添加了几个类路径,字符数超过9000.在测试环境中运行正常.它会在生产中引起任何问题吗?linux中设置类路径有任何限制吗?命令行输入的最大字符数是什么?

We are executing standalone java program from shell script, having a comman script to mention classpath, path, etc..In this common script, we have added several classpaths now and number of character is more than 9000. It is working fine in the test env. Will it cause any issue in Production? Any limitation is there in linux to set classpath? What is the max char for command line inputs...

推荐答案

不,没有限制.在Windows中有(8191个字符),但在Linux下没有.我们使用类路径文件的概念.这些文件列出了应用程序的所有依赖关系,例如:

No, there is no limitation. In Windows there is (8191 characters), but not under Linux. We work with the concept of classpath-files. These file lists all the dependencies for the application, eg:

...
libs/org/easymock/easymock/2.2/easymock-2.2.jar
libs/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar
libs/org/hibernate/hibernate-envers/4.1.0.Final/hibernate-envers-4.1.0.Final.jar
libs/com/google/inject/guice/3.0/guice-3.0.jar
...

然后将其转换为可用的类路径并按以下方式运行应用程序:

and then we convert this into usable classpath and run the application as follows:

#!/bin/bash

CLASSPATH_FILE=`ls -r1 ${APP-HOME}/classpaths/myapp*.classpath | head -n1`
CLASSPATH=$(cat $CLASSPATH_FILE | sed 's_^libs_ ${APP-HOME}/libs_' | tr -d '\n' | tr -d '\r' | sed 's_.jar/libs/_.jar:/libs/_g' | sed 's_.pom/libs/_.pom:/libs/_g')

java -d64 -cp $CLASSPATH com.blah.main.Main $@

我们从未遇到过问题,这些类路径条目变得非常庞大.

We have never run into problems and these classpath entries gets pretty huge.

作为旁注,您可以使用maven依赖插件来生成依赖列表.

As a side note, you can use the maven dependency plugin to generate a list of dependencies.

这篇关于Linux中的类路径限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆