简体   繁体   English

Eclipse 无法查看 class 文件

[英]Eclipse cant view class files

Everytime I try open a class file it gives me this error每次我尝试打开 class 文件时,它都会给我这个错误

rg.eclipse.core.runtime.CoreException: The Class File Viewer cannot handle the given input ('org.eclipse.ui.ide.FileStoreEditorInput').
    at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor.doSetInput(ClassFileEditor.java:652)
    at org.eclipse.ui.texteditor.AbstractTextEditor$19.run(AbstractTextEditor.java:3200)
    at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
    at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
    at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:759)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:756)
    at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2649)
    at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3218)
    at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3245)
    at org.eclipse.ui.internal.EditorManager.createSite(EditorManager.java:828)
    at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:647)
    at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)
    at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
    at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
    at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
    at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
    at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
    at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
    at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1245)
    at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1198)
    at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1597)
    at org.eclipse.ui.internal.PartStack.add(PartStack.java:493)
    at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103)
    at org.eclipse.ui.internal.PartStack.add(PartStack.java:479)
    at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112)
    at org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)
    at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:225)
    at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:213)
    at org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:808)
    at org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:707)
    at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:666)
    at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2942)
    at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2850)
    at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2842)
    at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2793)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2789)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2773)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2756)
    at org.eclipse.ui.ide.IDE.openEditorOnFileStore(IDE.java:1155)
    at org.eclipse.ui.internal.ide.actions.OpenLocalFileAction.run(OpenLocalFileAction.java:107)
    at org.eclipse.ui.internal.ide.actions.OpenLocalFileAction.run(OpenLocalFileAction.java:76)
    at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
    at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)

Though that might not be the correct error log.虽然这可能不是正确的错误日志。 What I've already done.我已经做了什么。

  1. Download JD-Eclipse from update site从更新站点下载 JD-Eclipse
  2. Set Class File Editor as default.将 Class 文件编辑器设置为默认值。
  3. Adding the class path to build path in project在项目中添加 class 路径以构建路径
  4. Asking this question on stackoverflow.com在stackoverflow.com上问这个问题

I'm using windows xp.我正在使用 windows xp。

Please help me请帮我

The Eclipse class file editor will not open a .class file that's not part of a java project in the workspace (so you can't use File > Open File... ) Eclipse类文件编辑器不会打开不属于工作空间中java项目的.class文件(因此您无法使用“ File > Open File...

You can open an enhancement request at https://bugs.eclipse.org/bugs/enter_bug.cgi?product=JDT&component=UI 您可以在https://bugs.eclipse.org/bugs/enter_bug.cgi?product=JDT&component=UI打开增强请求

thats all wrong you have to do: File ==> Open File ==> then go to your workspace an go in the project folder where the file is but dont go i the bin folder go in the src folder and open the file with .java at the end now you have the file open. 这就是你要做的全部错误:文件==>打开文件==>然后转到你的工作区,在项目文件夹中找到文件,但不要去bin文件夹进入src文件夹并打开文件。 java最后你现在打开文件了。

File ==> Open File ==> workspace ==> project folder ==> src folder ==> [Name].java File ==> Open File ==> workspace ==> project folder ==> src folder ==> [Name] .java

编辑器 - >文件关联 - > .java映射到Java编辑器(默认)

I was able to fix it by adding the folder that contains the class file(s) as a "Class Folder" under Project Properties => Java Build Path => Libraries => Add Class Folder. 我能够通过在Project Properties => Java Build Path => Libraries => Add Class Folder下添加包含类文件的文件夹作为“类文件夹”来修复它。

Once I did that, I was able to decompile all the sources properly. 一旦我这样做,我就能够正确反编译所有来源。 Just like the above comment mentioned, it needs to be a part of your workspace. 就像上面提到的评论一样,它需要成为工作区的一部分。

右键单击文件名,选择打开选项,然后按java编辑器选项。

I tried the JD-compiler but it did not work for me - I had to use the Class Decompiler Viewer available in the Eclipse Marketplace.我尝试了 JD 编译器,但它对我不起作用 - 我必须使用 Eclipse 市场中提供的 Class 反编译器查看器。

  1. Create new project创建新项目
  2. Add relevant source files to project将相关源文件添加到项目中

File -> Import "directory/folder" with *jar files into your project文件 -> 将带有 *jar 文件的“目录/文件夹”导入您的项目

Assuming that your class files are inside *.jar file.假设您的 class 文件位于 *.jar 文件中。

  1. Import Plug-in导入插件

Help -> Eclipse Marketplace Search and Install "Enhanced Class Decompiler" plug-in帮助 -> Eclipse Marketplace 搜索并安装“增强型 Class 反编译器”插件

  1. Set Preferences设置首选项

Window -> Preference -> General -> Editor -> File Associations Window -> 首选项 -> 常规 -> 编辑器 -> 文件关联

Configure both *.class and *.class without source as as Default to "Class Decompiler Viewer"将没有源的 *.class 和 *.class 都配置为默认为“类反编译器查看器”

Apply and Close申请并关闭

  1. Now, when I right-click and open a class file there is no error.现在,当我右键单击并打开 class 文件时,没有错误。

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

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