有没有一种方法可以在Intellij中更改“home”目录?

huangapple go评论73阅读模式
英文:

Is there a way to change "home" directory in Intellij?

问题

我正在使用IntelliJ IDEA,并且对Linux不太熟悉。例如,我有一个项目目录结构如下:

项目文件夹
|---> src
| | |---> MyCodes.java
| | |---> hello.txt

现在,如果我想在MyCodes.java中使用相对路径访问hello.txt,我需要使用"src/hello.txt",其中"home"目录是项目文件夹。然而,如果我将没有src文件夹的文件复制到Linux中,运行将会失败。有没有办法可以将src设置为"home",这样我就可以用相对路径简单地访问"hello.txt",即使在复制到Linux后也不会失败呢?谢谢!

英文:

I'm using intellij Idea, and new to linux
So for example, I have a project directory structure below

ProjectFolder  
|--> src  
| | |--> MyCodes.java  
| | |--> hello.txt  

Now, if I want to access hello.txt in MyCodes.java with relative path, I need to use "src/hello.txt", where the "home" directory is the ProjectFolder. However, if I copy my files in src(without src folder) into linux, it would fail to run. Is there a way I can set src as "home", so I can access with relative path simply "hello.txt", and therefore won't fail even after copying to linux?
Thanks!

答案1

得分: 0

可以在运行配置中设置工作目录

有没有一种方法可以在Intellij中更改“home”目录?

英文:

Yes, you can set the Working directory in the Run configuration:

有没有一种方法可以在Intellij中更改“home”目录?

huangapple
  • 本文由 发表于 2020年10月21日 01:19:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/64450271.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定