java 6 有通配符 , 即使不是java 6 也可以根据 shell的强大功能自动实现 批量

可以替代 ant 了 ,麻烦;;

我自己的案例:

以前用ant :

后来直接用java

java -cp "/home/work/dataio/WEB-INF/lib/*" com.baidu.adcoup.base.task.TaskScheduler Exception in thread "main" java.lang.IllegalArgumentException: The validated expression is false at org.apache.commons.lang.Validate.isTrue(Validate.java:158) at com.baidu.adcoup.base.task.TaskScheduler.main(TaskScheduler.java:12) ========= 结合eclipse的 remote project ( 先学会如何创建 create remote project ,再 到 java 视图下 , 右键项目 , 到 facets , 修改成 java 项目 ) , 可以实现linux 启动 debug 编辑 java ;; 不用再羡慕vim ;; 不用再怕直接调试linux的麻烦 ;; 彻底摆脱部署噩梦 ,执行噩梦;; 彻底摆脱编译噩梦;(依靠svn 同步代码, 但linux上编译整个项目 如何编译呢? ) 彻底摆脱要依靠hudson 自动部署,( 手工部署A1 .先windos编译 2. scp到linux( 这个过程超级麻烦 ,打包 , sz 手工部署B, 1 先ci代码 2.用svn下载下来, 3.然后借助ant 或者maven 进行 依赖编译 多个java ) ; maven+svn解决了轻量级更新代码+ compile 依赖控制; 或者借助于ant编译普通java项目;; 从此 java 也是 解释性语言, 而且方便的 import 管理 ,比 python等语言高端不少 ; 不用再羡慕 python , 也不要羡慕vim的超多高级功能 ==============================

If using Java 6 or later, classpath wildcards are a part of the JVM.

java
-cp "Test.jar;lib/*" my.package.MainClass

Key gotchas:

  1. Use quotes
  2. Use*only, not*.jar

The above example and gotchas are from other answers on this page. (Thanks davorp et al & Wim Deblauwe)

From theClasspathdocument section entitled,Understanding class path wildcards:

Class path entries can contain the basename wildcard character*, which is considered equivalent to specifying a list of all the files in the directory with the extension.jaror.JAR. For example, the class path entryfoo/*specifies all JAR files in the directory named foo. A classpath entry consisting simply of*expands to a list of all the jar files in the current directory.

A class path entry that contains*will not match class files. To match both classes and JAR files in a single directory foo, use eitherfoo;foo/*orfoo/*;foo. The order chosen determines whether the classes and resources infooare loaded before JAR files infoo, or vice versa.

Subdirectories are not searched recursively. For example,foo/*looks for JAR files only infoo, not infoo/bar,foo/baz, etc.

The order in which the JAR files in a directory are enumerated in the expanded class path is not specified and may vary from platform to platform and even from moment to moment on the same machine. A well-constructed application should not depend upon any particular order. If a specific order is required then the JAR files can be enumerated explicitly in the class path.

Expansion of wildcards is done early, prior to the invocation of a program's main method, rather than late, during the class-loading process itself. Each element of the input class path containing a wildcard is replaced by the (possibly empty) sequence of elements generated by enumerating the JAR files in the named directory. For example, if the directoryfoocontainsa.jar,b.jar, andc.jar, then the class pathfoo/*is expanded intofoo/a.jar;foo/b.jar;foo/c.jar, and that string would be the value of the system propertyjava.class.path.

TheCLASSPATHenvironment variable is not treated any differently from the-classpath(or-cp) command-line option. That is, wildcards are honored in all these cases. However, class path wildcards are not honored in theClass-Path
jar-manifest
header.

If you cannot use wildcards,bashallows the following syntax (wherelibis the directory containing all the Java archive files):

java
-cp $(echo lib/*.jar | tr ' ' ':')

(Note that using a classpath is incompatible with the-jaroption. See also:Execute jar file with multiple classpath libraries from command prompt)

Pasted from:<http://write.blog.csdn.net/postedit/9475103>

更多相关文章

  1. [java混淆器问题] 如何让web项目的class文件不能被反编译,又能在w
  2. java socket项目打包成可运行的JAR包!!!!!
  3. 阿里云服务器上部署java项目(安装jdk,tomcat)
  4. JAVASCRIPT实现翻页保存已勾选的项目
  5. Blue Pelican Java项目“Masking Telemetry Data”;编译但没有运
  6. java项目中Classpath路径到底指的是哪里?
  7. Java项目中的classpath
  8. r项目:xlsx包安装失败(由于java问题)
  9. vue、react等单页面项目部署到服务器的方法及vue和react的区别

随机推荐

  1. 分享新浪图床上传接口源码
  2. php实现对文件夹目录中的文件进行排序的
  3. Linux服务器查看 PHP 是否支持mail()函数
  4. PHP中如何通过getopt解析GNU C风格命令行
  5. PHP-Ajax实现异步上传图片到新浪图床
  6. 10 个 PHP 常见安全问题(实例讲解)
  7. nginx禁止指定目录运行php
  8. PHP-xml & jsonp转数组的方法
  9. 如何开启mysql和php慢日志
  10. php读取大文件的行数的方法