国产宅男网站在线|亚洲A级性爱免费视频|亚洲中精品级在线|午夜福利AA毛

  • <dd id="gf5jf"><th id="gf5jf"></th></dd>

    <cite id="gf5jf"><label id="gf5jf"></label></cite>
  • <div id="gf5jf"><listing id="gf5jf"></listing></div>
    學(xué)習(xí)啦>學(xué)習(xí)電腦>電腦安全>系統(tǒng)安全>

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

    時(shí)間: 黎正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比較麻煩。

      這個(gè)完全可以在IDEA的配置中的找嘛

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

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

      在彈出的“Project Structure”對(duì)話框中,選中“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

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

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

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

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

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

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

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

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

    2152640