About changes which are not reflected back in netbeans - java

I have a java source code of a project developed on netbeans IDE-8.0 and edited its GUI on netbeans.
After this i switched to eclipse IDE (kepler) and modified several files to implement some logic.
After implementing this logic i want to change GUI again but at this time netbeans is not showing the GUI changes in design view (but code is updated as changed is eclipse) which are made using the same IDE (before implementing the logic in eclipse).
I have tried several options like
cleaning and rebuilding.
coping the modified source code to another work space.
Also window builder in eclipse is not able to parse the GUI java file.
Any reply for any IDE will be appreciated.

Related

How I run individual java file in IDEA?

I am a java beginner, the first java IDE I downloaded was Visual Studio Code, it was very easy to use and everything is auto configured. But it kind overheats my laptop all the time, so I want to try IDEA, so far it's a very good experience, except when I open a java file and tried to run it in IDEA, it always pops out this run configuration window and I don't understand how to configure it. In visual Studio Code I can open any java file any time and run without any issues, but now I have to go through creating projects every time. Is there any solution for this?
From how the file icon looks:
your file is not recognized as the part of the sources of your project. Check the project settings to ensure that source directories are correctly set.
I'd also recommend you to look up and follow the conventions for the directory structure of java projects.
Once you've fixed the problem with sources, you'll see "run" icon next to your class, main method, or when you're right clicking the file.
Command-line
To run a single file, there is no need for an IDE.
In Java 11 and later, the java tool at the command-line can both compile and execute a single-file Java class. See JEP 330: Launch Single-File Source-Code Programs.
If your class named HelloWorld were in a file named HelloWorld.java, on a console type:
java HelloWorld.java
To be clear: The java command-line tool really only executes Java apps, while the javac command-line tool compiles Java source code. As a convenience, the java tool was enhanced to effectively call javac on your behalf for a single-file.
JShell
If you just want to run a few lines of Java, try JShell, the REPL tool bundled with Java 9 and later.
See:
Java Shell User’s Guide by Oracle
JEP 222: jshell: The Java Shell (Read-Eval-Print Loop)
Search to learn more and find tutorials.
BlueJ
Using an IDE such as IntelliJ, NetBeans, or Eclipse can be a daunting task for the new student of Java. Those IDEs are heavy-duty tools designed for professional programmers.
I recommend using an IDE designed for beginners. BlueJ comes to mind, designed specifically for educational purposes. BlueJ makes getting started with Java easier.
If you insist on using IntelliJ, read on.
If using IntelliJ, define a project
IntelliJ is not designed to work with single files. IntelliJ expects you to work within a project.
I strongly recommend learning the basics of Maven to create and drive your new project. By defining your project in Maven, the configuration is independent of any one IDE. You can move your project between major IDEs such as IntelliJ, NetBeans, and Eclipse.
Maven is also very useful for downloading needed libraries ("dependencies") that you may want to leverage in your work. And Maven is good at packaging your Java app as a JAR (or WAR or EAR).
In IntelliJ, choose "New Project". In the New Project window, click the Maven item on left. Check the Create from archetype box. Scroll the list to find item for org.apache.maven.archetypes:maven-archetype-quickstart. Under that, choose the "RELEASE" item. Click Next button.
In Name field, enter something like MyFirstProject. Click Next button.
On the Maven settings page, just click Finish.
Wait a moment for IntelliJ to download some stuff and configure your project. Eventually you should see a BUILD SUCCESS message in the Run pane.
You will also see a pom.xml file displayed. The POM contains your settings for Maven to run your project, in XML format.
Change the <maven.compiler.source> and <maven.compiler.target> elements to the version of Java you are using. The current version is Java 17.
After editing the pom.xml, look for a little floating windoid with a tiny Maven icon. Click the icon to have Maven process your changed POM. Wait a moment.
In the Project pane, navigate to the App file. There you see code to print “Hello World!”. Let's run that code now. Click the green triangle button on the left, in the gutter, next to the main method line. A pop-up menu appears offering a Run item. Choose that item to run the app immediately.
Down in the Run pane, you should see the results, the Hello World! text.
At this point you can add your single file to the org.example package seen in the Project pane.
By the way, you can change that package name by context-clicking and choosing Refactor > Rename….
Later, learn to use the Run/debug configurations feature of IntelliJ.
Know that you need not create a new project for each time you want to do a little experiment. Create one project for such experiments. Keep adding new .java class files for each experiment. Delete old class files you no longer need.
Eventually, I suggest updating the versions of various items in your POM. The QuickStart archetype is not configured for the latest versions (for reasons I cannot fathom).
And when you learn about unit testing, replace JUnit 4 in the POM with JUnit Jupiter (Aggregator) to use JUnit 5. One of the benefits of using Maven is that you can easily switch out dependencies such as going from JUnit 4 to JUnit 5.
The IDE needs to know what's called the entry point of the program, i.e. where to start running your code. That's what the "Edit Configuration" window is wanting you to do.
If your file "Lab3.java" is in a package, make sure to fully specify that in the field you have in red. Otherwise without knowing how your project is structured (as the other answer alludes to), it's difficult to pinpoint what we're missing here.
When you create your IntelliJ project, add a directory /src right at the root of your project. Right click on that folder and tell IntelliJ that you wish to mark it as a source root. The directory should turn blue in color.
Put your packages under /src. IntelliJ will know that those are Java files.
When you want to run a class with a main method, choose Run->Edit Configurations. Tell IntelliJ that you want to add an Application. It should prompt you with the classes that have main methods in them. You'll have no trouble running them.
Use Maven or Graddle. Make sure the project is configured with the build tool enabled and integrated, it will do basic things automatically. If you are not sure, please create a new project and add your files in. Steps:
Open the IDE
New Project
Choose from the left side bar "Maven" or "Graddle"
Give it a name and the location in your machine.
Click Finish
Now you have the project ready. You need the appropriate method to run in java. A main class. In IntelliJ you can just type "main" and the auto-complete will add it for you, make sure you inside the curly brackets of the class {}. More info about the main class. You seem to have this nailed down.
Lastly make sure you have a JDK installed in the IDE. I am pretty sure this is your issue here, make sure to use one of the option IntelliJ provides. A full guide from the developers is here and should satisfy your needs. I would suggest OpenJDK for a beginner, because that served me well at the beginning, at the end of the day its your choice.

Java source code management with different IDE

Is it necessary to use the same ide to program in java? For example, I use IntelliJ to build a small java project about 2000 lines. Then the marker uses Eclipse IDE to mark this project. Does he need to import all the source code into a new project and set up everything for it? I didn't use any add-on on this IDE.
The reason I asked this question because I receive huge grade duction for using different IDE, the prof response me and said marker need rebuild everything for using different ide.
I drag my source code into Eclipse, and it works very well, so I am confused am I right or wrong?

Error: Running JavaFX Appl outside Netbeans

everyone!
Here's the thing, I've been developing a JavaFX application with JDK 7u17 (That's the one Netbeans is compilling it, anyways) and I haven't had any problem testing it and running it through Netbeans itself. I simply click Run and it goes smoothly.
I'm creating the .jar files and the other (html, jnlp) through Clean-Build using Netbeans and the app does open perfectly when I execute the Jar.
The problem is when I try to navigate through the App, the app consists of 4 scenes (Login, Main, Search and Create) with me being able to log-in and head to the main scene but that's about it. The buttons to go to the search scene or create scene don't do anything nor I get an error saying something crashed (note I'm not using the console since I don't even know how to make it appear in runtime). I simply click them and they do nothing.
As I said earlier, the app runs perfectly when it's ran through Netbeans.
Some more info:
Netbeans Version: 8.0
Compilling Version through Netbeans: 1.7u17
Existing Java versions on System: 1.8u25, 1.7u67 and 1.7u17 (I already tried enabling only 1.7u17)
The App used FXML to switch between Scenes, it works great between LogIn and Main scenes.
What could it possibly be that it works great using Netbeans and break outside Netbeans?
EDIT #1:
According to the console (Thanks to #janih) I'm running Java version 1.7u17, same as Netbeans and it looks like it's working properly. The problem persists when I'm trying to run the same jar by simply doubli clicking it. It stops showing me controls (Third party controls).
I'm not sure but it could be this:
I was trying to run a project through the given .jar and had those results but that very Project was a plain JavaFX Project, not exactly JavaFX FXML Project and my Project uses FXML files to change between Scenes. What I did is redo the Project in FXML and worked perfectly.
Special thanks to #janih for the help.

How to up and run java code in JasersoftStudio?

I would like to know something if possible. As I used JaspersoftStudio, I noticed that when creating new project folder it always came up with JRE library. I also see java editor in there as well. Is it possible to write and run java code in JaspersoftStudio GUI?
Please share your ideas on here.
Regard,
Sakura
As you may have noticed, Jaspersoft Studio is a repackaged eclipse. And yes it is possible to run Java code in it, it's just a bit more cumbersome than in vanilla eclipse.
In any of your jasper projects (the project icon in the explorer should have a little J), right click and open Properties.
In Java Build Path, add a new source folder.
In your new folder, create a new File, and put your main class in it.
You can now run it with the keyboard shortcut Alt-Shift-x j. I don't know if there's a menu for that too.
Additionally if you have an existing eclipse project, you can import it directly into Jaspersoft Studio using Import... Existing Projects into Workspace.

UI changes done in Netbeans do not reflect in Eclipse

I am mainly using Eclipse for my project. For Swing GUI part, I find using Netbeans is more user-friendly. Hence, only for building UI, I am using Netbeans for the same project.
I developed a form using Netbeans. So, corresponding .java file got generated in Eclipse also. After working on it for few days, I went to Netbeans and changed name of a JPanel. But, the same change is not reflected in corresponding .java file in Eclipse.
Before this, I have done such changes in Netbeans and even have seen the changes getting reflected in Eclipse version of the project. But, I don't know what went wrong this time. I even tried refreshing, cleaning etc.
Can anybody please help me with this?
Thanks!
Finally, I had to delete everything from the workspace and checkout everything again. After that, it is working fine.

Categories

Resources