Trying to run decompiler in Eclipse Luna - java

I am trying to debug a jar file I don't have source for, in Eclipse Luna
I have tried various decompilers, and can't get things to run.
The most recent seems to be JDEclipse-Realign at http://mchr3k.github.io/jdeclipse-realign/
It installs without any trouble. I have set set the default file association for "class without source" to be "Class File Editor" like this
I added the jar file to be debugged as an external jar to my project. And when I expand that and right click on a .class file I get what is shown on the web page for JDEclipse-Realign, with Decompiled Source as the default.
And I am getting the blue and white icons for JDEclipse-Realign when I select a class file.
But no decompiled source :( And clicking the blue icon for Attach Decompiled Source does nothing.
I feel like I must be missing one basic thing, but can't figure it out. No errors, just no source.
Or should I be using a different decompiler?
Are any known to work in Luna?

Faced the same problem on Luna and did the following:-
Open Eclipse Luna
Go to HELP -> Eclipse Marketplace
In the find box, type "jad". [stands for Java Decompiler]
You will get a single result titles something as "JadClipse for Eclipse ".
Click on Install and restart eclipse when prompted. Your issue will be fixed.

Related

How to avoid Visual Studio Code warning: "[myfile].java is a non-project file, only syntax errors are reported"

I am running a build task in a Java project in Visual Studio Code.
The warning in the "PROBLEMS" tab:
[myfile].java is a non-project file, only syntax errors are reported
It refers to the first line where I load in the class file containing the main():
package [the project folder];
import [the project folder].[the file with other classes].*;
I can only avoid the warning by copying the files' text (the code text itself) into new Java files of a new project in a new unrelated folder. The code itself is correct and compiles without errors. Actually, this is the answer, but it is much manual work.
When I just copy the Java files of the project with the warning message into a new folder, the warning still appears!!!! (!)
When I just copy the whole project folder to a new place, the error remains as well, of course.
I guess that copying text into new Java files with the same names and the same folder structure is different from copying the files themselves because the files probably get tagged by Visual Studio Code, so that they have a project stamp even when the folder structure is destroyed. Perhaps this supports recovering the project structure from recovered raw files? Could this be the problem of this Visual Studio Code warning?
I checked other threads before, and this is just the last step.
How can I fix "build failed, do you want to continue"? In Visual Studio Code
Visual Studio Code - Java - Import Errors and More
--> Thus, I cleaned Visual Studio Code's workspaceStorage (on Windows: C:\Users\USER\AppData\Roaming\Code\User\workspaceStorage) and restarted without success.
Try cleaning the Java language server workspace:
Cmd + Shift + P (Ctrl + Shift + P on Windows) to show the command palette
Choose "Java: Clean the Java language server workspace"
Restart and Delete
It just worked for me.
I got the same warning simply because I had two Java (Maven) projects in the same Visual Studio Code workspace. Once I moved projectA out of the workspace, the warning for projectB was gone.
WorkspaceRoot
│ projectA
└───projectB
My current solution is to have one Java (Maven) project for one workspace, i.e, one Maven project per Visual Studio Code workspace.
My guess is that Visual Studio Code treats all Java projects inside the same workspace as as one project and hence, the projects interfering with each other.
This is an answer for those who do not use Maven.
The whole problem came up from loading not the direct project folder, but the parent folder, though the projects had been developed in their direct project folders from the start.
FOLDER1 (parent) contained
FolderA (direct project folder of Java files)
FolderB (direct project folder of Java files)
I have written the projects separately. But one time I opened the FOLDER1 in Visual Studio Code instead. That seems to have merged the two projects to just one project. After this, I changed back to opening only the FolderA/B and got the warnings that are reported in the question.
Now that I have opened FOLDER1 again and made both FolderA/B projects run without warnings (perhaps you might just comment out everything without fixing anything, but that is untested), opening the isolated FolderA/B projects threw no warnings either. It seems as if Visual Studio Code makes opening the parent folder the start of a new project which interferes with the child projects.
And the reason why I had a warning was a code error inside the other project's folder in the end (not important, but I had forgotten to load the local package needed for "FolderA" project at the start of some Java file).
Whatever error I had, the warning was confusing, as I was only working on project "FolderB" which had nothing to do with "FolderA" and which had no code issue. This led to the strange effect that I got the warning of the "FolderA" project also in my "FolderB" project, because Visual Studio Code considered both as one project.
I struggled with this for a long time, but I did not find a proper solution on the Internet. I somehow managed to do it by following these steps:
Here are the actions that I've performed:
There are folders you see in your left pane. (or press Ctrl + Shift + E to open the left pane).
Right-click on them one by one and press "Add folder to Java Source Path."
The one suggested in the solutions didn't solve my problem 100%. The problem with this extension occurred "Language Support for Java(TM) by Red Hat," which let our folder away from the source path.
Today I ran into this problem while going off-script during an Intro to Java tutorial video and somehow fixed it. This solution may not work for everyone.
Problems (1): [myfile].java is a non-project file, only syntax errors are reported.
How I fixed it...
I went to Java in Visual Studio Code and read sections "Working with Java source files" and "Working with Java projects". Basically, when working with "Java projects" in Visual Studio Code, you must have the necessary extensions installed to work with those project files.
In my case, I needed to build a Maven project supported through the extension "Language Support for Java by Red Hat" and "Server Connector by Red Hat", since one of the extensions did not come with Visual Studio Code's "Coding Pack for Java - Windows" or the "Java Development Kit: Amazon Corretto".
Once I had my extensions downloaded I opened the Command Palette (Ctrl + Shift + P) and typed "Java:Create Java Project" → "Maven" → "Maven-Archetype-Quickstart" → "1.4" → name] input group id → [name] input artifact id → then selected the folder I created that contained my Java file with the original error code (shown above). Once it was done processing, I reopened Visual Studio Code and opened my folder. Ran the program and the error went away.
You may have to copy/move your files manually or press Ctrl + Shift + E to open the left pane and add whatever you need to the Java Source Path.
I renamed the package which contains "[myfile].java is a non-project file, only syntax errors are reported" and it worked for me.
For me, removing the code folder in the C:\Users\yourHome\AppData\Roaming path solves the problem.
I have used the Visual Studio Code editor first-time for Java and I faced this issue with my simple Hello, World! program.
I tried to clean the editor's workspace, but the issue wasn't resolved.
Then, I created a folder named mypractice in the C:// drive. Following that, added the same in the Visual Studio Code workspace, and then created a Java file in that newly created workspace.
When I ran that file, it worked without any warnings or errors.
Instead of directly opening the Main.java file with Visual Studio Code Don't do this.
Open the folder in Visual Studio Code by selecting the 'Open with code' option after right clicking it in the folder and then run the program so it wont show that problem again Do this.
This is what helped me getting rid of that problem (Main.java is a non-project file, only syntax errors are reported), so I shared.
You should add your folder (in which your particular file is) to the workspace.
I have been running it a Dev Container/Docker image and multiple rebuilds have not been helping with this error. It has turned out I have accidentally created the directory in the root of the tree the current user had no access to. It has been the source of the issue.

Enable IndentGuide Eclipse plugin in java files

To install indentation in Eclipse I dropped this IndentGuide jar in the dropins folder (I couldn't install it in the "Install Software..." option as it's not available any longer).
I restarted Eclipse and I see the IndentGuide customization screen, but java does not show in available content types:
The indentation works fine in text extensions, but does not work for java. I looked at the eclipse/configuration folder but couldn't find anything. Any ideas?
UPDATE
This is what I see under Text > Java:
Update preferences to make it work with Java files

Opening source code from debug view edits .class after Android R18 update

When I'm debugging my code in Eclipse, I get annoyed when I open up the editor to find out I cant edit it because I'm actually viewing the source of the .class file. How do I get Eclipse to open up the .java file instead of the .class file when in debug mode?
EDIT: When I hit a breakpoint in my code, it brings me to MyFile.class, instead of MyFile.java, so I can see my code but not edit it.
EDIT: I'm guessing it has somethign to do with Android and ADT R18
After I finally found some time and good reason to look into this issue a bit deeper I'll elaborate a bit on Thornbjorn's answer.
As of lately, Google changed the way your Android projects package your external Android libraries. In ADT R17 (I think) it started packaging the external projects source into .jar files and including them directly into your project in the Android Dependencies or /libs folder.
Now, when the debugger hits a breakpoint, it brings up your source code in the .jar, essentially telling you to edit a .class file. The problem is that this file is read-only and so you have to go find your .java source manually. (Pain)
The fix is to right click the Project name in the debug view, and select "Edit Source Lookup..." from the menu. From there, remove the Default lookup path. After that, manually add the associated projects (not jars) that your project references. This is done by clicking Add, selecting Java Project, then checking the appropriate projects.
OK, so I hate to be "that guy", given the number of people for whom this worked, but this didn't work at all for me. I mean that the "Edit Source Lookup..." menu item was not in the context menu. I did not miss the instruction to do this in the Debug Perspective (presumably in the Project Explorer in the Debug Perspective). I tried it while the app was running and while the app was suspended. I tried checking the menu for the application's project (presumably what the instructions refer to) and for the library's project. No dice. This is with the latest Eclipse build.
However, I was able to resolve the issue:
Set a breakpoint in either your application or the library you are trying to link source for. You can actually put this anywhere as long as the library you are trying to link source for has a function that will appear on the call stack when the breakpoint is hit.
Start debugging your application.
Navigate your app to hit the breakpoint.
Make sure you are in the Debug perspective.
In the Debug tab (where the call-stack appears), find any function from your library.
Right-click that function. The "Edit Source Lookup..." menu option should be there (close to the bottom).
From here, the instructions are the same as Styler's. Click "Add", select "Java Project" and add your project (or multiple projects).
Before you exit the "Edit Source Lookup..." window, if you are like me, you will see that Eclipse has chosen to add a bunch of stuff to the list that you didn't choose. Some of that stuff (probably under expandable items with names like "Android Private Libraries" may be the jars for the libraries you just added source for. Remove those jars from the list.
Profit!
Open main project properties -> Java Build Path -> Projects tab and add there projects the main project depend on.
Switch to Order and Export tab and uncheck Android Dependencies
Enjoy
For some reason Eclipse does not believe that the class file comes from your Java file. This is frequently a malconfigured buildpath, or a jar-file used instead of the project generating the jar file.
Look in the project manager panel (<->button) to see where Eclipse finds the class file and then figure out why it uses that location instead of your project with the source file.

EGit opening .java files as plain text

So I've finally figured out how to use Git. (thanks to all the users here :)) And so I installed EGit on Eclipse. But now I have yet another problem:
So EGit works awesomely in Eclipse, and I can push/pull/commit/whatever else, but there's an annoyance: The whole reason I used EGit was so that I could edit the Java source code of a repository. But whenever I try to open a .java file from the repo, it just shows it like a text document. I've tried clicking "Java Perspective" but that just made the screen larger.
Is there any way to directly edit/save Java source files inside of Eclipse's Java editor if the source files come from EGit?
If you're editing files in Eclipse that are java files but are handled as text files instead this could mean that the project's nature or facet settings are not set to be Java.
To avoid the natures/facets mess in eclipse you can "clone" the repository into eclipse. You do this through the import dialog. Here are some instructions on how:
http://www.vogella.de/articles/EGit/article.html

Error: Unable to open class file R.java [duplicate]

This question already has answers here:
Developing for Android in Eclipse: R.java not regenerating
(64 answers)
Closed 9 years ago.
Did a fresh install of Eclipse, JDK and android-sdk.
I am currently receiving this error when creating a new project
[2010-09-26 16:07:56 - Test] ERROR: Unable to open class file C:\workspace\Test\gen\com\example\test\R.java: No such file or directory
What's the reason for this and how do I fix it?
Eclipse Helios 32 bit
java version "1.6.0_21"
Android sdk API 8
P.S. I'm new to Android development.
EDIT: I tried most of your solutions, but nothing worked. So I started using my friend's install of Eclipse Ganymede.
I have had same issue, all what I needed to do, was create project and restart eclipse.
//Edit: Complete collapsing of "Package" tree works as well.
This is a mighty annoying error.
It happens 100% of the time when I create a new android project.
What seems to work for me is to just delete the file (which DOES exist and is accessible by my user), then hit build, and it will regenerate it and stop moaning.
It's clearly a bug as there are too many people getting it simply by filling in the boxes in the new project dialog (like me) without even modifying any code!
Have a look at your console. It is an aapt aborted error. Since aapt is the tool that auto-generates R.java, therefore, R.java was not getting generated.
Since R.java is a auto-generated file that stores information about your drawables you should rebuild your project. Before that have a look at your layout xml files and check them for errors.
Notice that Project -> Build All should be selected. Also try to run your project.
Removing Read Only attribute on Eclipse workspace directory and Project->Clean->Build Project
did the trick for me. I then clicked on the project directory from within Eclipse and did a F5 (Refresh) . R.java was generated in the gen folder.
I had a similar error on the creation of new projects myself. After messing around I tried moving the R.Java file into the same location as my projects java file (the src file). Eclipse then saw I removed the R.Java file from its location and created another and that seemed to clean up the error.....I dont know if it was because eclipse rebuilt the file and then saw it or what but that seemed to work for now.
After creating the Project, Right click the Project Folder within the Project Explorer on the Left Tab of Eclipse.
Click on Source->Format.
The Console will say:
[2010-11-24 11:57:42 - YourProject] R.java was modified manually! Reverting to generated version!
Then you're good to go. Try running your Project and it will compile.
Check your imports. If this has sneaked in, then delete it.
import android.R;
Had a almost identical issue with Eclipse Helios 64 bit on Linux, but I had the "1.6.0" API selected like you. The bizarre thing was I could type;
cat <the path it was moaning about>
in a console it would display correctly.
I created a new AVD which used Android 2.1, the issue magically vanished. Perhaps it's a bug in Android SDK or Eclipse?
Right click on your project name in package explorer. Then click 'Validate'. It will be fine.
Here is how to fix it:
Go to your "workspace" folder and make sure it's not "read-only"
Eclipse Menu > Projects > clean
Had the same issue.I was able to solve it by doing the following:
go to Window/Preferences/Java/Build Path
select 'Folders' and change the output folder to 'gen' (this is where Android looks for the generated java files,but the default in eclipse is 'bin').
restart Eclipse
Windows 7,Eclipse 3.5.2
Configure buildpath.. check android , it worked, of course i followed one of the posts mentioned above window, preferences, java, java build path and selected project,
then created a project, and tried to build same error, then i checked build path and saw android is unchecked, checked it and build again, it works!
I had this exact same problem with no helpful errors. finally, I tried deleting my debug keystore and it worked:
rm ~/.android/debug.keystore
I had seen people mention that, but I figured it wasn't my problem because I wasn't getting any errors relating to the debug keystore. I found the answer here:
"Debug certificate expired" error in Eclipse Android plugins
apparently the debug keystore is only valid for one year.
I would say that once you have created your project and you've mention the R.class error --> just restart the Eclipse IDE and everything will be fine ;)
1.-Open Eclipse
2.-Open Window/Preference
3.-Expand JAVA option
4.-Select Build Path
5.-Check the option "Projec"t and uncheck "folder" options
6.-Click on OK
7.-Restart eclipse IDE
Let's go to code !!
This problem can be solved by merely cleaning and rebuilding the project. How ever there is a link to the latest version of Eclipse for Android.
**Eclipse Java EE IDE for Web Developers.
Build id: 20100218-1602
(c) Copyright Eclipse contributors and others 2005, 2009. All rights reserved.
Visit http://www.eclipse.org/webtools**
Here is a link to Android Tutorial with Eclipse
http://developer.android.com/resources/tutorials/hello-world.html
In mac,
I select Project>Clean
after that, i unchecked Build Automatically
then i run the project and it works :)
Windows 7 64bit, run eclipse as administrator, solved the problem for me.
In my case there was no gen folder after pressing clear...
To solve it, i created a new gen file, then when to Build Path => Configure Path, and pressed ok.
All went smooth after that :-)
Following steps are done as solutions:
1. Collapse the project tree structure
2. Go to the workspace and remove the readonly permission of the workspace.
3. right click "default.properties" and go to properties and uncheck the readonly permission in eclipse.( this is done when the workspace shows build error even though there are no compilation issues)

Categories