How to refactor properly in Netbeans? - java

I'm working with JavaFX and whenever I move a class to another package I have to update all my FXML files to point to the correct location of classes.
In Eclipse you get an option to apply refactoring changes to the XML files and even non-code text files. However Netbeans only makes changes in Java code and nothing else.
Is there a workaround for this problem?

Related

Intellij doesnt show package option when I right click

Intellij doesnt show package option when I right click, I was trying to create new package on my project.
I am adding the screenshot. Is there anybody know the solution?
enter image description here
Make sure that
the module of the Java type
the directory where you are trying to create a package or a Java/Kotlin class is marked as a source root type.
The question already answered, as per the following thread there is very little difference between directories and packages in java parlance.
Marking a directory as the source root means, it contains all the necessary code which will be deployed and will be required to run the application.
In my personal experience I could not find a way to create classes when the directories were just directories, but marking them as source root and tells IntellJ Idea that the source code is here so it can highlight them and actually look for errors and support us in our development of application.

Moving multiple classes to another package and reconfiguring the package in each file

I have a lot of classes within a package and I have to move them to another package. I'm using Eclipse IDE and after moving them, I have this problem of editing each class file's first line (the "package" line)
For example, I have to change the line:
package abc.def.xyz;
to
package abc.def.hij.xyz;
is there a better way than to open each file and manually do it? I'm not a familiar with the IDE and I've looked around for a better way in Google but no solution yet. I have a lot fo things to move.
The error will come in case where you are manually moving classes directly to another package in your workspace.
Instead of doing this go to package explorer of your Eclipse IDE, I guess there will be multiple packages in your projectname->src folder(If it is simple java project type).
Now just select the java files from one package in your package explorer and drag them to target package.
Doing this will show a "Move" popup with auto selected checkbox "update references to classname.java", just press Ok.
This will just change the reference of your classes and you do not have to change the package name manually to all of your classes.
I hope this helped.:)

Java class editor like eclipse viewer

I decompiled a Java .jar file, after editing the problem i'm having with it, its not compiling again. So, i had to opt-in to using 7-zip to just bring out the class file and, now i've used 5 different Class Editors, all can't show me the codes like i can understand...
I used CE(Classeditor.sourceforege.net), dirtyjoe, javaeditor(javaeditor.org), Jad and JD-GUi(Seems not to do its work at all)
I imported the .jar file into Eclipse as a Project Reference Library and the most painful thing is i can see all of the class codes, but i can't edit it...It won't edit. But, it can run.
What can i do to Eclipse to be able to make it allow editing the .class files attached to it.
EDIT: I want A Class Editor That Shows in Codes Format, not bytecodes.
I have the source as well in .java format.
This Example is Eclipse Class Viewer(I want same, but not only viewer).
Eclipse Class Viewer Image, I want something similar
It sounds like you want to be able to edit class files directly. The Eclipse class viewer only works because it finds (in your project folder or online) a source code version of the jar that you're viewing. It's not actually looking at the class files and decompiling them, AFAIK. So, if you can view the source in Eclipse, your best bet may be to find the source version of the jar (on your machine or on maven, possibly, if you're using maven), and then edit it and build it yourself according to that project's build instructions. How hard that is depends on the library.
As far as being able to decompile, edit, and recompile, I'm not sure. I know that decompilers are not foolproof, and I've only used them as a last-ditch, read-only tool. It seems like it should work both ways, but I wouldn't be surprised to hear it doesn't.

Executable jar file won't run after doing some updates

I am working on Java project (A terraria like sandbox game) and I have come across something that I just don't understand. I have been exporting the project as .jar's as I go along to upload and share with my friends, but the last time I did this, the .jar won't run, but when I run it in eclipse, it runs fine. When I try to run the jar all it does is lose focus on the explorer window for a split second, then goes back. I have tried many things, like changing the main class, changing the META, and moving the files to specific packages, but nothing is working.
The project is 9 classes, so I won't paste all the code for it here, but the latest, non-working source code can be found here (http://www.mediafire.com/?fiw6wq73j7cff4t), the non-working jar here (http://www.mediafire.com/?bhjo162oh3hi2j9), and the working jar here (http://www.mediafire.com/?h918s8xpyxw4psr). If someone with more experience in java could please take a look at this it would be much appreciated.
One of the things I tried was not adding the JPanel (the game), and just leaving the splash screen, and the jar worked. This shows that it must be a problem in the coding somewhere.
Thanks for the time,
I.D.
Couldn't find message comes from your ReadMap class. So check which circumstance leads to this error. Most likely you did not add all classes or other files to your JAR, so file is not found. Check that all needed files are added to exported JAR in Eclipse export dialog. It's also a good idea to provide more debugging info (stacktrace is ok), especially when you are studying. BTW, cool game :)

JFormDesigner generating Java Code in Eclipse

I am using JFormDesigner to develop a Swing application. However I can't seem to get the package to generate java code. I tried saving the form and also pressing the "Generate Java Code" button, but it is not working. Is there some setting that I need to put in place for this to work?
Here is an uppdate. The generated code file is in my workspace directory, but Eclipse is not refreshing the file. Also, I note that the icon next to the file name in the navigator view looks different than normal java files. So really, this seems to be a problem with Eclipse refreshing. And yes, I've tried manually refreshing. But it is not doing this. Why would that be?
Thanks,
Elliott
The code is there. But is collapsed. You need to click on the + sign next to the position in the module where the generated code should be and it appears.

Categories