简体   繁体   English

将GitHub存储库克隆到IntelliJ IDEA Java类中

[英]Cloning GitHub repo into IntelliJ IDEA java classes

I work from two different laptops and naturally use GitHub VCS to link the my work among the machines. 我使用两台不同的笔记本电脑工作,并且自然使用GitHub VCS在机器之间链接我的工作。 I recently started a Java project where the .class files are saved in the src/ directory. 我最近启动了一个Java项目,该.class文件保存在src/目录中。

Whenever I clone the remote repo into my 2nd machine none of the classes will run. 每当我将远程存储库克隆到第二台计算机中时,所有这些类都不会运行。 I have the proper SDK/JDK assigned and setup. 我已经分配并设置了正确的SDK / JDK。

here is the error message: 这是错误消息:

/usr/lib/jvm/java-7-oracle/bin/java -Didea.launcher.port=7532 -Didea.launcher.bin.path=/home/me/idea-IC-141.1532.4/bin -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/java-7-oracle/jre/lib/resources.jar:/usr/lib/jvm/java-7-oracle/jre/lib/management-agent.jar:/usr/lib/jvm/java-7-oracle/jre/lib/deploy.jar:/usr/lib/jvm/java-7-oracle/jre/lib/charsets.jar:/usr/lib/jvm/java-7-oracle/jre/lib/rt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jce.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jsse.jar:/usr/lib/jvm/java-7-oracle/jre/lib/javaws.jar:/usr/lib/jvm/java-7-oracle/jre/lib/plugin.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jfxrt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jfr.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunec.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunpkcs11.jar:/home/me/idea-IC-141.1532.4/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain HourglassFigure
Exception in thread "main" java.lang.ClassNotFoundException: HourglassFigure
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:195)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)

Process finished with exit code 1

I suspect the .iml files is to blame? 我怀疑应该归罪于.iml文件? or is it also because I am using .gitignore? 还是因为我正在使用.gitignore?

Whenever I create a new IDEA project and merely copy the code into a new java class file the code executes without flaws. 每当我创建一个新的IDEA项目并将代码复制到一个新的Java类文件中时,代码就可以毫无缺陷地执行。

As a rule of thumb I don't check in IDE settings because they may vary between machines (like JDKs may be in different locations, IDE-specific executables may be at different paths etc.). 根据经验,我不会检查IDE设置,因为它们在计算机之间可能会有所不同(例如JDK可能位于不同的位置,IDE特定的可执行文件可能位于不同的路径等)。 This is the IntelliJ/sbt-related excerpt of my .gitignore: 这是我的.gitignore的IntelliJ / sbt相关摘录:

target/
.project
.idea*
/project.plugins/project
ca.log
*.iml

So add that to your .gitignore, set up the project on both machines and see if it works. 因此,将其添加到您的.gitignore中,在两台计算机上都设置项目,然后查看其是否有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM