java获取class所在jar
2024-08-25 12:49:32
在类库的开发过程中,有些时候为了self-contain的原因,我们希望所有的资源都打包在jar中,但是有些工具好像无法支持从classpasth直接获取比如velocity的模板合并,此时我们就知道class所在的jar,然后通过jar方式加载velocity资源模板。
String jarFilePath = clazz.class.getProtectionDomain().getCodeSource().getLocation().getFile();
// URL Decoding
jarFilePath = java.net.URLDecoder.decode(jarFilePath, "UTF-8");
- String jarFilePath = clazz.class.getProtectionDomain().getCodeSource().getLocation().getFile();
- // URL Decoding
- jarFilePath = java.net.URLDecoder.decode(jarFilePath, "UTF-8");
最新文章
- 给缺少Python项目实战经验的人
- C++中int,float,string,char*的转换(待续)
- NEC学习 ---- 模块 -多行式面包屑导航
- EXCEL 保存之前校验
- Apache Spark源码走读之20 -- ShuffleMapTask计算结果的保存与读取
- HDU 5441 Travel (并查集+数学+计数)
- JDBC连接(MySql)数据库步骤,以及查询、插入、删除、更新等十一个处理数据库信息的功能
- Lambda(Linq)
- ogg的孩子-无损音频编解码flac
- 在java中实现数据导入excel表格中
- 分享一个公众号h5裂变吸粉源码工具
- 如何将文章列表用<;li>;分两列显示
- rsync命令解析
- 跟我学SharePoint 2013视频培训课程——理解SharePoint网站的体系结构(3)
- DispatcherServlet的url mapping为“/”时,对根路径访问的处理
- CF3A 【Shortest path of the king】
- C# 实现将listview中已经显示的数据导出到Access 数据库
- 學習Extjs比較好的資源
- 最大匹配算法 (Maximum Matching)
- “全栈2019”Java第六十章:如何定义接口
热门文章
- Could not find the Visual SourceSafe Internet Web Service connection information for the specified database Would you like to launch the Visual sourceSafe connection wizard?
- WinStore控件之Button
- ubuntu 修改默认root及密码
- 正向代理VS反向代理 总结
- windows环境下配置php和redis
- MYSQL开发性能研究&mdash;&mdash;批量插入的优化措施
- MyBatis知多少(8)关系型数据库
- js中的执行上下文,菜鸟入门基础。
- 在C函数中保存状态:registry、reference和upvalues
- CentOS linux系统搭建LAMP环境