Eclipse and class files - java

I've got some class files that open in Netbeans (with .java extension) but in Eclipse I had the following experience:
At first I could not see the content of the class files with jadclipse and I only saw:
/jadclipse/
//Error!
A few days later (without any change to eclipse or ...) I could see them but with errors like the ones bellow:
"Couldn't fully decompile method ...
Couldn't resolve all exception handlers in method ...
Overlapped try statements detected. Not all exception handlers will be resolved in the method ..."
But the other day I ran into the first error that I could not see anything again!!!
OS: Win7
Java: 7
Netbeans 7.1.2
Eclipse version Juno Service Release 1
Any suggestion?

I didn't get any help on Eclipse plugin of JAD as I said it didn't work for my class files. So I tried Java Decompiler GUI and it worked very nice, therefore I wanted to share this nice experience so that it might be useful for some body.

Related

Java & Eclipse :: Eclipse Doesn't Recognize Common Packages in an Imported Project

I have what is probably a stupid question... but here goes anyway. Some years back, I wrote a "Star Trek" game in Java 8, using JavaFX and Eclipse IDE. The project grew to be fairly large, but it worked. When I finished, I made sure to export the project using Eclipse's File --> Export menu.
I recently grew nostalgic and decided to import the "Trek" project into Eclipse on my current laptop. (The original laptop died.) FYI, my current version of Eclipse is Version: 2018-12 (4.10.0), which I thought was pretty recent.
The project imported just fine, but Eclipse seems mystified by everything in it. For example, when I try to compile and run the project, this error comes up immediately:
Error: Could not find or load main class gameEngine.MainEventTrek
Caused by: java.lang.ClassNotFoundException: gameEngine.MainEventTrek
gameEngine.MainEventTrek contains the project's main() method. Eclipse can't find it??? But the java file is right there, right in the project's src directory:
That's not all. When I open the Java files, Eclipse seems ignorant of how to import common packages:
Look at that; Even line 1 has an error! ("The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files") I can understand that Eclipse might not know about JavaFX - I can't remember if I installed it - but Eclipse doesn't seem to know about common packages like java.math and java.util. Heck, later in my code, Eclipse doesn't know what the System package is, so all my System.out.println() commands are now throwing errors.
I'm a fairly good Java coder, but I'm pretty stupid when it comes to resolving basic compiler issues like this. Does anyone have any idea what the issue might be and how I go about fixing this? Thanks... and Live Long and Prosper.

Can't get Atom editor ide-java package to work on new Mac installation

I have recently been using the Atom editor with its ide-java package to do some Java development. It has worked well enough for me and I'd like to continue to use it.
I have just refreshed my Mac from scratch after having some repairs done on it that required erasing the disk. Since installing on this refreshed Mac, I am getting red error highlights on pretty much every line of code, including the first line of files which start with a comment. Most of the errors have a message something like this:
The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
A Google search shows this error and some fixes within Eclipse projects, but I am not (directly) using Eclipse and I've had a hard time figuring out how to fix the problem in ide-java.
I've tried deleting the .project file and the .settings folder and allowed them to be auto-regenerated. I've tried uninstalling and re-installing the ide-java package. I've tried setting the package's Java Home to both a Java 8 and a Java 10 home folder. None of these have made a difference.
Can anyone offer any advice on how to troubleshoot and make this work as it has for me in the past?
To fix this - you can try to reset atom settings.
For linux:
mv ~/.atom ~/.atom.bak
You will have to install packages again, but this helped me to fix the issue

.class file stopped getting generated suddenly in Eclipse IDE

I am working on an automation project where I automate manual processes of general insurance sector using JAVA and SELENIUM WEBDRIVER. I have created a java project in eclipse. Inside it under src I created a single package containing 6 .java files.
I wrote 90% of the code and tested all the files. They were running properly and showing the automated output. One day I appended some lines of code to a java file. It was called from main method class where main method class suddenly started showing error under the name of that class. Firstly it said to import the class which itself was in the same package of main class. Secondly even after clicking on importing command of the class the error did not went away.
Lastly I cleaned the project in eclipse and the error went away but when I tried to run the project then it gave the error as NoClassDefFoundError and ClassNotFoundException. I checked the bin folder inside the project folder on drive. There .class file for the error class was missing while other classes .class file was present. Everytime I make changes in the main method class and save it eclipse starts showing error under that class name. The error goes when I clean the project. It is a repetitive occurrence in eclipse.
Code for all java classes without main method are 99% same still error is coming for one java class only while other java classes are running fine with almost the same lines of code
Can anyone please explain me the reason behind such behaviour of java compiler in eclipse. Its really a strange show of java compiler the reason behind which I am not able to understand. Please do let me know about the reason behind this act of JAVA compiler in eclipse as I am very curious to know the reason for it. I use jdk 1.8 and selenium standalone server ver 3.0.1
Thanks in advance for your answer.

Java decompiler plugin not working

I have the JD-eclipse-plugin installed. I want to decompile the classes within a jar-file. So I select the jar-file within Project-Explorer and click Decompiler in the Menu. However both decompilers (JAD and JD-core) are greyed out.
I also tried the steps shown in this blog on AVAJAVA Web Tutorials. I guess the blog is a bit outdated, however I can see within Windows-->Preferences-->Java-->Decompiler that Jad is correctly set up. But there is no JD-eclipse found within Preferences-->General-->Editors-->File Associations as you can see in the following image.. Now I right click the jar-file within Project-Explorer, but there is no such "Attach Source File".
Did I miss anything to set up the plugin?
EDIT: I´m using the following setup: Eclipse: Mars.1 Release (4.5.1); JadClipse 4.0.0; JDK 1.8
EDIT2: Forgot to mention that I use Tomcat and want to dive into the libraries from /WebContent/WEB-INF/lib. This is not working, I cannot further collapse the jar-files.
For Eclipse 2018-09 , the problem was related to " class without source
"
I had resolved this issue by going to:
Preferences
General
Editors
File Associations
Class without source
and setting decompliler viewer as default : see the following screen shot:
Obviously I mixed the actual JD-eclipse-plugin an a plugin called JadClipse for Eclipse which is a slightly different plugin from eclipse marketplace. Thus when I followed the installation instructions of JD-eclipse, I could set the options for the screenshot posted within the question. So I set JD-eclipse as default for both *.class-files with and those without source-code.
Second mistake I did was a pretty silly and obvious one, namely that I wanted to browse the jar-files from within WEB-INF-folder of my Tomcat instead of from within Java Resources. Thus I could not dive into the jar-files at all hindering me to get to the class-level and thus to decompile those classes contained within the jar.
I hope this helps anyone outside also having trouble with the plugin for eclipse.
I had the same problem but "class without source" did have decompliler viewer as default. So all I did was set class file viewer as default and then switched back and that fixed the issue.
I had to update all of my plugins. the Procyon decompiler has this symptom when running under java 11 or later.

Java and Scala ClassNotFoundException after upgrading to IntelliJ 14

I recently upgraded to IntelliJ 14, then added Scala support.
My main files stopped running. For example the GUI file, which has no errors and is a totally self contained hello world style for testing this error:
Exception in thread "main" java.lang.ClassNotFoundException: GUI
It makes no sense and I'm pretty frustrated that the IntelliJ devs are slacking in not auto-detecting a solution to this. I have tried everything to fix it. From settings, compilers, to making the project from scratch.
I only had a bit of luck when making it from scratch, but as soon as I started to add my other files (files that were not even being used!) it starts with the error.
It seems that any files outside of the original project module (when creating a new project to test fix) will not run giving ClassNotFoundException.
This may be related to my other question: https://stackoverflow.com/questions/27516673/cannot-run-file-located-out-of-main-module-intellij-14-java-scala
Sample View of the problem
I had the same problem and was able to fix it by right clicking the directory my class was in, and clicking Mark as sources root. This should make your class discoverable and able to run.
Solution
Turns out that Make, No Error Check does not work the same for scala as it does for Java.
Errors in the scala files will cause an ambiguous error message on run, with no clear link to the error.
Fixing the scala files fixes the error.
In my case, the solution was at the JDK and java level.
When I set JDK 14 this error occurred.
So when I work with a scala project, I set java 8 everywhere in the project(module) settings and in the configuration of the main method.
In project(module) settings section: Project, Modules, SDK's
In main method settings: JRE

Categories

Resources