導航:首頁 > 文件目錄 > java獲取jar文件路徑

java獲取jar文件路徑

發布時間:2024-11-22 15:47:36

java項目的jar在哪個目錄下

是web項目嗎?web項目中的WebRoot下面的Webinfo下面的lib裡面。

Ⅱ [java]打包成jar之後找不到文件FileNotFoundException

Java在WEB項目中獲取文件路徑 .

jsp中獲得文件路徑servlet中獲得文件路徑java中獲得文件路徑jsp中獲得文件路徑
1、根目錄所對應的絕對路徑:request.getRequestURI();
2、文件的絕對路徑:application.getRealPath(request.getRequestURI())
3、當前web應用的絕對路徑:application.getRealPath("/")
4、取得請求文件的上層目錄:
newFile(application.getRealPath(request.getRequestURI())).getParent()
servlet中獲得文件路徑
1、根目錄所對應的絕對路徑:request.getServletPath()
2、文件的絕對路徑:
request.getSession().getServletContext().getRealPath(request.getRequestURI())
3、當前web應用的絕對路徑:servletConfig.getServletContext().getRealPath("/")
註:ServletContext對象獲得幾種方式:
javax.servlet.http.HttpSession.getServletContext()
javax.servlet.jsp.PageContext.getServletContext()
javax.servlet.ServletConfig.getServletContext()
java中獲得文件路徑
1、Thread.currentThread().getContextClassLoader().getResource("").toURI().getPath()
2、MyClass.class.getClassLoader().getResource("").toURI().getPath()
3、ClassLoader.getSystemResource("").toURI().getPath()
4、MyClass.class.getResource("").toURI().getPath()
5、MyClass.class.getResource("/").toURI().getPath()
6、newFile("/").getAbsolutePath().toURI().getPath()
7、System.getProperty("user.dir").toURI().getPath()

希望能幫到你

Ⅲ java jar包獲取當前路徑是哪個路徑

獲取jar包的路徑的方法:
xxxxx.class.getProtectionDomain().getCodeSource().getLocation()
其中xxxxx是類名

Ⅳ 在java下如何訪問將要打包成的jar所在的路徑

例如:Java Web Project 中,導入JDBC的jar包。

一、首先將jar包存放到 lib 目錄下。

Build Path 是載入jar包路徑。

Ⅳ Java如何獲取當前的jar包路徑以及如何讀取j

舉例:
把配置來文件ccc.xml放到編源譯路徑,如src/com.aaa.aa下面,然後再根據
String rootPath=Xxxx.class.getResource("/").getPath();
獲取到編譯的根路徑,配置文件的地址就是rootPath+"com/aaa/aa/ccc.xml"

Ⅵ JAVA如何在main()中取得當前jar的名字和路徑

java 允許我們定位某個 class 的 CodeSource 。
通過 CodeSource 提供的 Location 信息就能夠找到相關的文件路版徑。權
假設 aa.jar 的 main class 是 Test,通過
new Test().getClass().getProtectionDomain().getCodeSource().getLocation();
可以獲取到jar包的路徑。jar的名稱就好辦了。截取下上面獲取到的路徑字元串就行了。

閱讀全文

與java獲取jar文件路徑相關的資料

熱點內容
哪個app可以賣二手課程 瀏覽:474
互聯網app如何算毛利 瀏覽:300
excel文件處理插件 瀏覽:666
在電腦上怎麼找不到微信文件夾 瀏覽:116
u盤打開後有文件沒內容 瀏覽:210
編程怎麼輸出逗號 瀏覽:421
微信玩紅包怎麼定大小 瀏覽:825
電腦病毒測試代碼 瀏覽:118
得物app為什麼總是更新 瀏覽:965
銀企對賬程序 瀏覽:164
r讀取excel文件 瀏覽:363
上古卷軸5控制台附魔代碼 瀏覽:514
緩存文件合並找不到文件 瀏覽:871
桌面保存一下文件找不到 瀏覽:645
程序美工標准 瀏覽:191
漂流瓶的文件在哪裡 瀏覽:319
數據的正負偏差怎麼計算 瀏覽:242
文件名用不用帶TXT 瀏覽:968
小米十數據線是哪個 瀏覽:463
caddws文件 瀏覽:962

友情鏈接