Netbeans & JavaFX - Clean and build on each run? - netbeans

I recently started working with JavaFX at the Netbeans IDE. I come along with the Hello World examples as it is not that complicated, but there is one big thing that is totally annoying me:
As within my FXML project, I have to Clean & Build the whole project before changes get applied.
Is this normal?
May I skip this?
Working on my Lenovo Yoga, Clean & Build & Run takes more than a minute! That's way to long for one single changed character.
I'm using:
Netbeans version: 7.2.1
Project type: JavaFX FXML
JDK: 7
Also, I can't select the Properties -> Build -> Compile -> Compile on Save checkbox.

Netbeans 7.2.1 does not support Compile on Save for JavaFX projects, so you have to manually recompile the project each time.
One alternative is to create a normal Java project, import the JavaFX JAR (jfxrt.jar IIRC). Compile on Save will be available and you won't have to recompile the whole project every time you make a change (although you should still run a "clean and build" before releasing your project).
When doing that, you might lose a few JavaFx-related features - not completely sure.

Related

what is the right way of importing a maven project in Eclipse and run it as a Java project?

I don't understand exactly what is the way of working with maven projects in Eclipse.
The problems I have are often with projects I download from github. If I set the project myself it usually work, so I think I'm doing something different from the majority of people.
I'll try to detail a specific case:
I clone a repo, let's say: https://github.com/spring-guides/tut-spring-boot-oauth2
In Eclipse I import "existing maven project"
The project has a "Maven nature" as indicated by M on the folder icon
I try to run java class with main from Eclipse. First strange thins is that the "Run As" menu doesn't have "Run as a Java application"
I have to configure the configuration manually. Now it runs, but strange things happens, like I can't edit the file as the "content assist" throw errors instead of giving the normal assists.
I notice that the project has no "source folder". So my first instinct is to add a Java nature or select src as source folder
So I add Java nature to the project. This is a disaster. It can compile anymore as it can find packages. All classes have errors. I try to play around setting source folders on /src or /src/main/java. Sometimes I fix the errors but I can't run (and now I have run as Java application) but when I run it can't load the class
So in the end, I'm a bit confused and I don't know if I explained clearly what I'm doing.
I think I would like to know in a simple way how people are doing it, rather than trying to correct my steps as I'm probably creating a mess myself.
Any help or suggestion welcome.
I'm using the last version of eclipse. I don't know which other tool's versions are relevant.
P.S. I also refresh,restart,clean rebuild the project often after touching things...but it doesn't get better
Maven is a build (management) tool. Simply spoken, its task is to create a JAR that can be used as a dependency/library by other projects or when running java -jar ....
Running a project's code isn't part of it (apart from unit and integration tests code and by using non-default plugins for special situations). Running code is part of Eclipse (or any other IDE) with its Run Configurations.

Do I need 10 step process to make jar file in Eclipse? [duplicate]

This question already has answers here:
Build project into a JAR automatically in Eclipse
(7 answers)
Closed 7 years ago.
I sincerely hope the answer to my question will be no.
I just wanted to quickly test a hypothesis on a simple java program (4 lines). I already tested that with C++ in Visual Studio where the experiment took 5 minutes.
Eclipse is different. First, I was unable to find where did it save my project - unlike NetBeans or Visual Studio, it doesn't provide Open in file browser option.
Afterwards I had to google up "create jar file eclipse" since Project -> build does not seem to produce a jar file, or anything else for that matter. The article I found is correct and works. But it has 10 steps and actually doing the thing takes long time because you have to specify the main class every time.
Is that normal? I make simple test programs quite often, this is definitely gonna slow me down a lot.
To clarify the question: How to quickly create a project and produce a jar file in Eclipse? (time limit 180 seconds)
You can always right click a project in Eclipse and pick the option "Export", which will lead you to create a jar/Runnable jar file. Another option would be to transform your projects into Maven Projects and then run maven install with the target packaging set to jar. Another way would be to directly compile your code using the javac : http://www.skylit.com/javamethods/faqs/createjar.html
Since you are testing small stuff, you have a lot of options which may fit you, and the answer is not bound to an IDE (Eclipse) for example
You don't have to produce a JAR to test a program in Eclipse. You can right-click on any class, package, or project that includes an appropriate main(String[]) method, and select Run or Debug.
Use Show in > System explorer from the context menu on the project (or any file) to open Windows Explorer (or whatever your OS uses).
If you just want to test some lines of code, there is no need to create a jar file at all, just use the Run As > Java application menu.
Once you get used to it the eclipse tooling for java is no worse than that of netbeans. And I've never found building java applications with either tool to be much different than building c# projects in Visual Studio.
As for having a main class, not every type of application requires you to create one. It's no that much different than c++ is in that respect, is it?
Take a look at this thread:
Build project into a JAR automatically in Eclipse
It seems any number of those methods would take less than 3 minutes. And once you do it once (for example using an ant file), future builds will take seconds.
Also, look at this maven article:
https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
Five minutes from the command line. The eclipse tooling will cut that down considerably.

Scala IDE 4.0.0 thinks there's errors in an out-of-the-box Play Framework 2.3.7 program

I've created a Play Framework program via Typesafe Activator (so it follows the template exactly).
I used sbteclipse-plugin version 3.0.0 to create an Eclipse project and imported that into Scala IDE 4.0.0. These are all the latest versions at the time of writing.
The Scala IDE definitely seems to support the Play Framework. It has syntax highlighting for the custom formats, including the routing file and templates. Yet, it doesn't seem to be able to find the views from the controllers. In particular, the call to views.html.index triggers an error: "object index is not a member of package views.html".
I tried enabling refreshing using native hooks or pooling as detailed here, but it had no affect.
I should note that while the code has been compiled in the command line (with activator ~run), it hasn't been compiled in Scala IDE, since I don't know how to (it doesn't seem to be documented anywhere).
What can I do to get rid of these false errors?
EDIT: After running activator clean ~run, I have another error: The project cannot be built until build path errors are resolved. There's no further details on what these build path errors are.
Update: Just upgrade to sbteclipse version 5.1.0 and everything should work out of the box. Also make sure you follow the Play documentation on how to set up Eclipse/ScalaIDE.
This is a known bug in sbteclipse, which probably will be fixed soon.
For now, you can add the following line to your build.sbt:
EclipseKeys.createSrc := EclipseCreateSrc.All
Kill the SBT console and run sbt eclipse again. That should add the following line to the .classpath file within your project folder as a workaround:
<classpathentry kind="src" path="target/scala-2.11/twirl/main"/>
Refresh your Eclipse project to pick up the change.
I had the same issue, also with Scala IDE 4.0.0 . I followed mkurz instuctions and they worked like a charm. But instead of changing the .classpath file in the project folder manually I used Eclipse interface:
In the top menu of the main window, click on Project and then on Properties.
In the Properties window, click on Java Build Path option (options list is on the left)
In the Source tab, click on Add Folder... button.
In the Source Folder Selection window, choose the target/scala-2.11/twirl/main folder, so it is included in the compilation path. Click Ok button.
Click Ok in the Properties window.
Now the project should compile just fine :) . With that I was able to finish the play setup example in Scala IDE website
I tried #mkurz solution first, but also ran into the same error as #matt. I became frustrated that I could not generate the eclipse project without having to go to the Eclipse project properties to manually fix the build errors. After some investigation, I discovered the solution that removed all errors entirely. Add this your build.sbt:
unmanagedSourceDirectories in Compile <+= twirlCompileTemplates.target
Or if that does not work for you, you could also use:
unmanagedSourceDirectories in Compile <+= target.zipWith(scalaBinaryVersion) { (b,v) => b / s"scala-$v/twirl/main" }
Good bye, build errors!
I got the same error message.
Are you using java8 as jre in eclipse?
After switching back from java8 to java7, everything worked fine again.
If, after following Mkurz' instructions (adding EclipseKeys.CreateSrc... ), your problems are not solved, click on Project -> Properties -> Java Build Path. Look at the source folders tab.
You may find a duplicate file folder named .../src_managed/main (Thanks Matt). If so, close the project. Remove ONE of the two ../src_managed/main entries from the .classpath file (located in the base of the activator/SBT project directory). Reopen and clean the project and you should be good to go.
For me, it turned out that installed JRE in the Scala IDE was openjdk, changed it to Oracle Java 8 and it worked.

How to use eclim with gradle project

My eclim setup working perfectly with eclipse project. But I want to use gradle build system.
I am working with Libgdx framework and it provide gradle templete project.
So is there any way to use eclime + eclipse + gradle
Your best bet is to check out the Eclipse Gradle plugin, although in short you can add apply plugin: 'eclipse' to your project and then run gradle eclipse from your terminal in the root folder of your project. That should generate the necessary files for Eclipse to recognize your project, although you might need to edit the .classpath file for proper autocompletions.
That will get Eclim to recognize your project with :ProjectOpen and proper autocompletion and other goodness.
The bad is that Gradle tasks and changes to your build.gradle will require manual changes to the Eclipse side of things.
Edit: There's a new plugin available for this purpose that replaces eclim for gradle projects (but is android oriented) called Vim-Grand. It's pre-alpha and you'll want the refactor branch for now, but it's working well enough for me
You should combine it with YouCompleteMe.
What I did was use the gdx-setup.jar to create my project. I then imported it into eclipse like a normal gradle project. I closed eclipse and started up elcimd. Put "let g:EclimCompletionMethod = 'omnifunc'" in my .vimrc file. Followed the elcim instructions to use :CreateProject and that was it.
This guide was really helpful: http://www.lucianofiandesio.com/vim-configuration-for-happy-java-coding
I am able to get most or all Eclim functionality working with my libgdx project this way:
create a new libgdx project with their tools
start Eclipse
Import --> Gradle Project --> Build Model per usual libgdx project creation
shut off Eclipse, start Eclim
I get organize imports, java validation, autocompletion, all the good stuff.
That said, I want to figure out how to do this all without having to use Eclipse. I think the missing piece is the Build Models functionality. Still researching ...

Compile and run a netbeans project with terminal

So I created a project in netbeans and then added a new JFrame form (this is my first gui app). I was wondering if there was any way to open the source code in another app like textedit and compile it using terminal (javac blah.java, java blah).
I managed to create a .jar file (clean and build) and it works perfectly fine when I try to run it (double click). Now I managed to find the .java file in src but when I compile it I receive 36 errors, which makes no sense since it built and ran perfectly fine and the jar file works.
Essentially I want to just take the source code (not the entire project) and compile it, for example on a computer that does not have netbeans using terminal. Can this be done?
I would also like to emphasize that I'm just a beginner. Thanks!
Standard NetBeans projects are based on Apache Ant. So it should be sufficient to install Ant and a JDK to compile/package your project on another computer or CI system.
What i found to be the culprit to this problem is that on your source code make sure it does not have package. So for example:
"package blablah"
All you have to do is get rid of that, and then take your java file and it should compile perfectly. For some reason that causes the nodefclass error.