精品丰满熟女一区二区三区_五月天亚洲欧美综合网_亚洲青青青在线观看_国产一区二区精选

  • <menu id="29e66"></menu>

    <bdo id="29e66"><mark id="29e66"><legend id="29e66"></legend></mark></bdo>

  • <pre id="29e66"><tt id="29e66"><rt id="29e66"></rt></tt></pre>

      <label id="29e66"></label><address id="29e66"><mark id="29e66"><strike id="29e66"></strike></mark></address>
      學(xué)習(xí)啦>學(xué)習(xí)電腦>電腦安全>系統(tǒng)安全>

      java怎么獲取項(xiàng)目路徑

      時間: 黎正888 分享

      java怎么獲取項(xiàng)目路徑

        Java中項(xiàng)目路徑,就是classpath了。下面就讓學(xué)習(xí)啦小編教大家java怎么獲取項(xiàng)目路徑吧。

        java獲取項(xiàng)目路徑的方法

        項(xiàng)目路徑,就是指classpath的根路徑了。

        是查找配置文件和classloader加載bytecode的起點(diǎn)

        這次就以IntelliJ IDEA為例,來聊聊項(xiàng)目路徑,也就是classpath的事

        前面分享了一篇classpath和path的區(qū)別,有興趣的tx可以去看看

        使用Java API來查看。

        Code:

        public class ClassPathDemo {

        public static void main(String[] args) {

        String classPath = ClassPathDemo.class.getResource("/").getPath(); System.out.println("項(xiàng)目路徑:" + classPath);

        }

        }

        執(zhí)行上述代碼,看看打印的信息

        Output:

        項(xiàng)目路徑:/E:/java/JavaStudy/out/production/JavaStudy/

        在使用IDEA的過程,通過API查看項(xiàng)目路徑來找編譯好的class比較麻煩。

        這個完全可以在IDEA的配置中的找嘛

        下面就分享下在IDEA配置中怎么查看項(xiàng)目路徑,也就是找到執(zhí)行代碼的classpath

        在Project 面板中點(diǎn)右鍵,在彈出的菜單中選“Open Module Settings”

        在彈出的“Project Structure”對話框中,選中“Paths”Tab選項(xiàng)卡

        在Compiler output中,默認(rèn)選擇的是“Inherit project compile output path”

        也就是當(dāng)前module使用的是Project的Compiler output路徑。

        那么Project的Compiler output路徑在哪呢?

        點(diǎn)左側(cè)的“Project”選項(xiàng),在右側(cè)窗口可以看到Project的compiler output

        這個路徑是不是和JAVA API的輸入基本是一致的呢。

        “This directory contains tow subdirectories:Production and Test for production code and test sources,respectively.”

      java怎么獲取項(xiàng)目路徑相關(guān)文章:

      1.java簡歷中項(xiàng)目經(jīng)驗(yàn)怎么寫

      2.JAVA工作經(jīng)驗(yàn)簡介 java簡歷中項(xiàng)目經(jīng)驗(yàn)怎么寫

      3.java簡歷項(xiàng)目經(jīng)驗(yàn)怎么寫

      4.java簡歷項(xiàng)目技術(shù)怎么描述

      5.JAVA如何獲取計算機(jī)硬件信息

      2152640