eclipse的classpath(build path)和classpaht几种设置的方式
1,默认eclipse有自己的classpath的路径并不是环境变量中配置的classpah.
2,eclipse的classpath每个项目不同,一般是在工作区的当前项目的class下。
2.1,可以通过下面代码查看:
System.out.println(System.getProperty("java.class.path"));
2.2也可以通过eclipse菜单查看:
Run→Run Configures...在classpath选项卡下就会发现,Eclipse默认是没有导入系统的CLASSPATH路径的
3,可以通过eclipse添加自己指定的classpath路径:
1,在工程上右击→Properties-java build path,在Libraries选项卡下,Add External Class Folder...,选择自己需要导入的类文件夹
2,完成之后你会在工程下面看到Referenced Libraries
4,修改classpah的几种方式:
,当然就是直接在环境变量设置
,在dos中使用set classpath=路径
3,在dos使用java -cp 路径
(cp是classpath的缩写,dos环境设置的只是临时的,窗口关闭也就失效了)
,在代码中设置System.setProperty(“java.library.path”,“classpath路径”)
但是在代码修改有个问题:
那就是classpath对应的是系统类加载器(AppClassLoader),那就是在代码运行前系统类加载器已经实例化,也就是classpaht已经被确定了。
那么指定的路径可能并不会起作用,路径下的类会出现找不到的异常。
虽然修改了classpath的值,但是类加载器已经启动了,再修改其classpath的值已经对那个已经启动的类加载器或者说是jvm不起作用了。
google关键词:“setting the classpath at runtime” 在此我贴出一些解释
)The classloader represents (part of) a namespace, and two otherwise identical classes loaded by different classloaders are not “equal”. Which means there are a few dangers lurking in classloading, notably singletons suddenly not being so single anymore as well as casts failing unexpectedly.
)Classloaders (should) work on a pattern of delegating to the “parent” loader before attempting anything themselves (see above).
)Class loading and linking are two distinct steps (even though example implementations of a classloader such as may be found in blog posts/online Java articles, will combine the two into one for simplicity) Therefore you should not assume that if a parent loader has loaded a class it has also loaded all dependencies …
)All this means there is a problem if class A loaded by loader A references a class B which neither loader A nor any of its parents can load: class A may load just fine in loader A but at the point of use it fails because loader A cannot fully resolve (link) it.
)And you should make sure that your classloader loads classes in a synchronized manner otherwise the issues hinted at in step # can leap from duplicates due to classloaders to duplicates from multiple threads using the same classloader as well…
eclipse的classpath(build path)和classpaht几种设置的方式的更多相关文章
- 大杂烩 Classpath / Build path / Debug关联源码 / JDK&JRE区别
Classpath的理解及其使用方式 原文地址:http://blog.csdn.net/wk1134314305/article/details/77940147?from=bdhd_site 摘要 ...
- eclipse中Build Path-Add to Build Path相应到androidstudio的设置
有些时候并不须要加入lib库进行编译,比如在使用xposed的jar包时,仅仅须要在eclipse里Build Path-Add to Build Path就可以,假设作为lib库加入进去反而会出现异 ...
- Eclipse中Java build path的使用
1.Eclipse中,工程属性的Java Build Path的Library标签页下,有如下几个按钮:Add Jars...添加JAR包,是指本Eclipse当前包含的工程中的,在工程列表下选取即可 ...
- Eclipse下Java Build Path下Libraies中添加 Maven dependencies 失败解决方案
当maven 仓库有jar时,tomcat生成时总是报javaclassno..........无这个文件:用一下方法 转载:http://bugyun.iteye.com/blog/2311848 ...
- eclipse 右键没有Build Path
如果Project Explorer右键没有build pathWindow ->show view 选择package explorer 参考https://blog.csdn.net/cod ...
- eclipse 工程没有build path
项目的.project文件添加: <buildSpec><buildCommand><name>org.eclipse.jdt.core.javabuilder&l ...
- eclipse中java build path下 allow output folders for source folders 无法勾选,该如何解决 eclipse中java build path下 allow output folders for source folders 无法勾选,
在创建maven工程时,在设置output folders时,总是勾选以后,老是自动恢复到原来的状态,对比其他的maven的工程发现是在创建maven时候选择的项目为pom,而不是war或者jar,将 ...
- Eclipse中的build path详解
http://blog.csdn.net/qqqqqq654/article/details/53043742
- java环境配置classpath和path变量的作用及设置方法
1.path:指定cmd中命令执行文件所在的路径.比如javac.java两个可执行文件在jdk的bin目录下,如果path值含有这个bin目录,在cmd下执行这两个命令的时候就会到path指定的目录 ...
随机推荐
- 命令: go build
命令: go build 参考: https://studygolang.com/articles/9463 go help build 构建编译由导入路径命名的包,以及它们的依赖关系,但它不会安装结 ...
- WebApi参数传递总结(转)
出处:http://www.cnblogs.com/Juvy/p/3903974.html 在WebAPI中,请求主体(HttpContent)只能被读取一次,不被缓存,只能向前读取的流. 举例子说明 ...
- Oracle学习笔记(十三)
十四.触发器(监听数据操作的工具) 1.什么是触发器? 数据库触发器是一个与表相关联的.存储的PL/SQL程序 作用: 每当一个特定的数据操作语句(insert.update.delete)在指定的表 ...
- tomcat服务器输入localhost可以访问,ip无法访问解决办法
最近在开发项目中,遇到的一个问题是: 在 tomcat中发布一个web项目,但是发布成功后,只能用http://localhost:8080/fm访问项目,不能用 http://127.0.0.1:8 ...
- jmeter 计数器 (可自动生成新数字、注册专用)
1.打开jmeter,创建好线程组后,添加计数器 2.设置计数器 3.添加HTTP请求,验证所设置的计数器 4.填写对应参数 5.添加查看结果树,查看结果 6.修改一下线程属性 7.跑一下,看下结果就 ...
- 18-11-2 Scrum Meeting 5
1. 会议照片 2. 工作记录 - 昨天完成工作 1 把数据导入数据库 2 中译英选择题和英译中选择题的查询接口 - 今日计划工作 1 配置页面 2 实现中译英选择题和英译中选择题的查询接口 3 整理 ...
- Android-操作系统拨打电话广播的处理
Android操作系统的 packages/apps/phone/AndroidManifest.xml源码阅读 在之前的博客,Android-隐式意图激活操作系统通话界面,讲解了,阅读Android ...
- Linux文件扩展思考随笔
Linux文件时间 ============================================================ ls -l 文件名 仅看到的是最后被修改的时间 Linux ...
- tomcat启动时就频繁gc和full gc
一个小业务,流量并不大,功能也很简单,spring framework+mybatis+quartz,一启动就看到gc的频次和full gc的频次非常高: 4.202: [Full GC 4.202: ...
- Android 属性动画实现一个简单的PopupWindow
1.今天看到一个PopupWindow的效果如图: 2.其实就是属性动画的一个简单实用就ObjectAnimator就可以的,想实现更多,更灵活的可以用ValueAnimator 3.直接上代码: p ...