git 克隆后无法在eclipse中运行git项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16244795/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't run git project in eclipse after clone
提问by jalone
I've been following this guide to set up a git environment in eclipse for a java project, but I could not get rid of this error.
我一直在按照这个指南在 eclipse 中为一个 java 项目设置一个 git 环境,但我无法摆脱这个错误。
I've been able to set up a repositoryon (hope i can write it) GitHub and push a project with EGit plugin for eclipse juno.
我已经能够在(希望我能写出来)GitHub 上建立一个存储库,并使用 Eclipse juno 的 EGit 插件推送一个项目。
Then I deleted the local project and did the clone procedure (this becouse it was supposed to be easier than associate a local project to the remote one).
然后我删除了本地项目并执行了克隆过程(这是因为它应该比将本地项目关联到远程项目更容易)。
I seemed to work, since i can now see the repository in repository view, and I am able to perform all basic git commands(always through gui, since i am on Windows and i am not used to this OS).
我似乎工作了,因为我现在可以在存储库视图中看到存储库,并且我能够执行所有基本的 git 命令(总是通过 gui,因为我在 Windows 上并且我不习惯这个操作系统)。
Then I Build the project and seems to works (there are some errors relative to other used projects and jars or library, but it has always worked and are not important), until I Run and it does not work at all and the only thing it says is
然后我构建项目并且似乎可以工作(相对于其他使用过的项目和 jars 或库存在一些错误,但它一直有效并且不重要),直到我运行并且它根本不工作并且唯一的事情说是
Errore: impossibile trovare o caricare la classe principale myPackage.MyMainClass
错误:不可能 trovare o caricare la classe principale myPackage.MyMainClass
that in italian (why the hell error messages are localized???) roughly means
在意大利语中(为什么地狱错误消息被本地化???)大致意味着
Error: impossible to find or load main class myPackage.MyMainClass
错误:无法找到或加载主类 myPackage.MyMainClass
i belive the problem is related to git and classpath, since git projects are not stored inside workspace, they are in the git folder, and inside them no bin is present.
我相信这个问题与 git 和类路径有关,因为 git 项目没有存储在工作区中,它们在 git 文件夹中,并且在它们里面不存在 bin。
i don't even know now where are the .class supposed to be created, wether in the workspace or in git folder, neither i know what to write in the .classpath to link (if it is right) to the correct project location... since i have a lot of projects i should edit all of them?
我什至不知道现在应该在哪里创建 .class,无论是在工作区还是在 git 文件夹中,我也不知道在 .classpath 中写什么来链接(如果它是正确的)到正确的项目位置。 ..因为我有很多项目,我应该编辑所有项目吗?
edit: same procedure on an mac-osx platform produced same error:
编辑:mac-osx 平台上的相同程序产生了相同的错误:
Exception in thread "main" java.lang.NoClassDefFoundError: mypackage/MyClass
Caused by: java.lang.ClassNotFoundException: mypackage/MyClass
at java.net.URLClassLoader.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
edit: some things from eclipse error log
编辑:Eclipse 错误日志中的一些内容
eclipse.buildId=M20130204-1200
java.version=1.6.0_43
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Framework arguments: -product org.eclipse.epp.package.jee.product -product org.eclipse.epp.package.jee.product -keyring /Users/jalone/.eclipse_keyring -showlocation
Command-line arguments: -os macosx -ws cocoa -arch x86_64 -product org.eclipse.epp.package.jee.product -data /Users/jalone/programmazione/java/workspace2 -product org.eclipse.epp.package.jee.product -keyring /Users/jalone/.eclipse_keyring -showlocation
Error
Fri Apr 26 17:04:32 CEST 2013
The project description file (.project) for 'TheNameOfTheProject' is missing. This file contains important information about the project. The project will not function properly until this file is restored.
and this is weird since it is present, but obviously only in the git folder.
这很奇怪,因为它存在,但显然只在 git 文件夹中。
采纳答案by jalone
I fixed it somehow. Almost editing some random settings i ended up in
我以某种方式修复了它。几乎编辑了一些我最终得到的随机设置
Right click on project > Run As > Run Configurations...
右键单击项目 > 运行方式 > 运行配置...
then in Source tab only Default folder was present, and i noticed tat my Project was present but with a weird path like /NameOfTheProject. So i left it it as it was but i added again my project with 'Add...'
然后在“源”选项卡中只存在默认文件夹,我注意到我的项目存在但有一个奇怪的路径,如 /NameOfTheProject。所以我保持原样,但我再次添加了我的项目“添加...”
Then i run and everything worked fine. This is really weird, and i am trying to commit this setting at least, but i can't find in which file it's stored.
然后我运行,一切正常。这真的很奇怪,我至少尝试提交此设置,但我找不到它存储在哪个文件中。
If someone else give me a better answer ill accept it happily.
如果其他人给我一个更好的答案,我会高兴地接受它。
回答by Andrew Eisenberg
It sounds like you did not push your .classpath and .project files to github. I am guessing that your projects no longer look like java projects to Eclipse. In the project icon in the package explorer, do you see a little 'J' on it? Also, do you see a package icon on your src folder? If not, then you did not properly commit your project metadata files.
听起来您没有将 .classpath 和 .project 文件推送到 github。我猜你的项目对于 Eclipse 来说不再像 Java 项目了。在包资源管理器的项目图标中,您是否看到上面有一个小“J”?另外,您是否在 src 文件夹上看到包图标?如果不是,那么您没有正确提交您的项目元数据文件。
If this is the case, I'll explain an easy way to fix this.
如果是这种情况,我将解释一个简单的方法来解决这个问题。