简体   繁体   English

将Eclipse中的Java项目从Windows导出和导入到Linux

[英]Exporting and importing java project in Eclipse from Windows to Linux

I'm trying to migrate my java project from my windows machine to my linux machine. 我正在尝试将Java项目从Windows计算机迁移到Linux计算机。 I'm using Eclipse's import/export function. 我正在使用Eclipse的导入/导出功能。

This is how the structure looks like on windows: 这是在Windows上的结构: 窗户结构

but when I import on the linux side the structure is completely different... and it doesn't work. 但是当我在linux端导入时,结构完全不同...并且不起作用。

linux结构

I also tried moving the files/folders directly into the workpath. 我还尝试将文件/文件夹直接移到工作路径中。 That kept the structure in place, but when trying to run the files, I only got an "does not contain a main type" error. 这样可以使结构保持在适当的位置,但是在尝试运行文件时,仅出现“不包含主类型”错误。

Exporting/Importing from windows -> windows works just fine. 从Windows导出/导入-> Windows效果很好。

Any Ideas why this happens? 任何想法为什么会这样?

I solved the problem now. 我现在解决了这个问题。 For some reason the Java version was set to 1.4 in the .project file... don't ask me why. 出于某种原因,.project文件中的Java version was set to 1.4 ...不要问我为什么。 That was the source of the errors in basically every file since this version doesn't support things like the diamond operator and annotations. 这是基本上每个文件中的错误的根源,因为此版本不支持菱形运算符和注释之类的内容。

To do this I went into Project -> Properties -> Java Compiler -> untick "Enable project specific settings" 为此,我进入了Project -> Properties -> Java Compiler -> untick "Enable project specific settings"

Probably one of the more unusual issues I had so far and I have no clue why something like this would be set as default. 到目前为止,可能是我遇到的不常见的问题之一,我也不知道为什么将这样的问题设置为默认问题。 On a positive note the structure created by the import function was not the issue at all. 积极的一点是,导入功能创建的结构根本不是问题。

The differences you are seeing in the view structure is that you are using a different view on Linux and Windows. 您在视图结构中看到的差异是您在Linux和Windows上使用的视图不同。 On Linux it looks like you are using the standard Java view called Package Explorer that collapses packages and puts nice icons for "source" folders. 在Linux上,您似乎正在使用称为Package Explorer的标准Java视图,该视图折叠包并为“源”文件夹放置漂亮的图标。 The Windows screenshot looks like a Navigator View. Windows屏幕快照看起来像一个“导航器视图”。 Unfortunately is it hard to be sure as the screenshot does not show the view name. 不幸的是,由于屏幕截图未显示视图名称,因此很难确定。

Here is a screenshot showing both views side by side on my Linux computer for a simple project: 这是一个屏幕快照,显示了一个简单项目在我的Linux计算机上并排的两个视图:

意见

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

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