maven does not include fxml file - java

I try to create a maven project of a java program, which includes two java classes and a fxml file, which are all located in the same directory (src/main/java/package).
When i install the project with maven it does not copy the fxml file into the .jar file so that the program does not work any more. A few hours ago I basically created an equivalent project and everything worked fine.
How can I fix that?

The Maven convention is that Java files go in src/main/java. Any non-Java files go in src/main/resources.
The Eclipse emulation of Maven does not make this distinction. Both directories are source folders which is incorrect but "good enough" to handle correct Maven projects.
So, move your file to the correct location.

Related

The xml files are not compiled into classes folder in Intellij

I have a maven project which has many modules, I imported it to my Intellij as a maven project.
In the project settings, I changed the Project compiler output to xxx/src/main/webapp/WEB-INF/classes, the absolute path of my project. And also, I changed the Compiler output of all the other modules to this location. But when I check the classes folder at this location, I found two things which I think are not right:
The xml files are not compiled into the related path under the
classes folder, which are under the java folder instead of the
resource folder in source code.
There's a production folder under the classes folder, the classes
of other modules in it as the path they should be.
I'd be appreciated if anyone can help me understand this. Thank you in advance.
I'd recommend the following changes:
Your project compiler output folder should not follow the WAR standard. Make it /target, separate for all your artifacts. IntelliJ will create a /production and /test folder and put the .class files there.
Your XML files should be under /resources in the Maven convention.
You need to create an artifact for your deployment. That is where the WAR standard comes into play.
If you follow the conventions correctly IntelliJ will build and run your application perfectly.

Where to get the .java files of a netbeans project?

As you might notice, I'm quite new to netbeans and programming in general.
I've been working on a small project (homework) and now I need the .java files from one of the packages. When I build the project, i get a .jar archive with all the classes. When I compile the package I need, I get a .jar archive of the .class files of this package (in the "build" folder of the project). However, I need a zip archive of the .java files of this package. I'm a little embarassed to ask, but where do I get these from?
Thanks,
Zhao Nan
From the Projects window (Window-->Projects) or Ctri-1
Navigate to the .java file you want, and right-click on it, and select Properties. The path to the file is shown under All Files.
To see the path to the project right-click on the name of the project (in the Projects window), select Properties, and the project folder is shown under Sources-->Project Folder
If your are on windows, usually if you let netbeans create all by it self it creates a directory called
NetbeansProjects
Under "documents"
There will be a folder list of all your projects. Under the project name that interest you, go in the "src" folder. All your java files should be there.
On Ubuntu 16.04 using NetBeans IDE 8.2, a folder called NetBeansProjects was created in my root directory, parallel to the netbeans-8.2 directory. I'm guessing that this was suggested at installation time and can be configured differently.

Copying a .jar file from my system to the disk -- is there a general solution for both .jar projects and non .jar projects?

My current project has a folder with dependencies, that is, .jar files. I was wondering if it'd be possible to copy any one of those .jar files to my disk.
I'm currently developing this project as a standard Eclipse Java project, but one day I'll want to deploy this project as a .jar file, too, so the solution would have to work both for the moment, and for the future situation as well.
Thanks
I Think this is what you are after:
Eclipse has an export function that also packages used library jars into the exported jar.
File->Export->Runnable Jar file -> Package Required libraries into generated JAR

What's in an Eclipse .classpath/.project file?

We recently had an issue with an Eclipse project for one of our team members. Tomcat was not deploying JARs of the application.
We eventually noticed the .classpath Eclipse file was not the same as for the team members where the project was OK. We replaced the .classpath file with one from a project that was OK and the Tomcat deploy was complete.
Just out of curiosity and to know at what to look in the future if something is wrong, what is inside the .classpath and .project files. What can I add in there, what does it all mean?
Eclipse is a runtime environment for plugins. Virtually everything you see in Eclipse is the result of plugins installed on Eclipse, rather than Eclipse itself.
The .project file is maintained by the core Eclipse platform, and its goal is to describe the project from a generic, plugin-independent Eclipse view. What's the project's name? what other projects in the workspace does it refer to? What are the builders that are used in order to build the project? (remember, the concept of "build" doesn't pertain specifically to Java projects, but also to other types of projects)
The .classpath file is maintained by Eclipse's JDT feature (feature = set of plugins). JDT holds multiple such "meta" files in the project (see the .settings directory inside the project); the .classpath file is just one of them. Specifically, the .classpath file contains information that the JDT feature needs in order to properly compile the project: the project's source folders (that is, what to compile); the output folders (where to compile to); and classpath entries (such as other projects in the workspace, arbitrary JAR files on the file system, and so forth).
Blindly copying such files from one machine to another may be risky. For example, if arbitrary JAR files are placed on the classpath (that is, JAR files that are located outside the workspace and are referred-to by absolute path naming), the .classpath file is rendered non-portable and must be modified in order to be portable. There are certain best practices that can be followed to guarantee .classpath file portability.
.project
When a project is created in the workspace, a project description file is automatically generated that describes the project. The sole purpose of this file is to make the project self-describing, so that a project that is zipped up or released to a server can be correctly recreated in another workspace.
.classpath
Classpath specifies which Java source files and resource files in a project are considered by the Java builder and specifies how to find types outside of the project. The Java builder compiles the Java source files into the output folder and also copies the resources into it.
Complete reference is not available for the mentioned files, as they are extensible by various plug-ins.
Basically, .project files store project-settings, such as builder and project nature settings, while .classpath files define the classpath to use during running. The classpath files contains src and target entries that correspond with folders in the project; the con entries are used to describe some kind of "virtual" entries, such as the JVM libs or in case of eclipse plug-ins dependencies (normal Java project dependencies are displayed differently, using a special src entry).
This eclipse documentation has details on the markups in .project file: The project description file
It describes the .project file as:
When a project is created in the workspace, a project description file is automatically generated that describes the project. The purpose of this file is to make the project self-describing, so that a project that is zipped up or released to a server can be correctly recreated in another workspace. This file is always called ".project"

Which files in a Java Netbeans project should be placed under version control?

I'm working on a Java Netbeans 6.7 roject with a few developers and we're using Mercurial for version control. I was wondering what I should put in the .hgignore file (ie. what files should not be added to the repository). I know I will definitely want the src, test, and lib folders in the repository and the build folder to not be in the repository. But I'm not sure what to do about the nbproject folder.
You must ignore the following folders: build (or nbbuild), dist (or nbdist), and the nbproject/private.
And if you want others to open it with netbeans (as you do in netbeans) you must add nbproject folder.
Though nbproject/private should be ignored, nbproject should be
checked into the version control system.
If you want more information, see netbeans help on http://netbeans.org/kb/docs/java/import-eclipse.html#versioning
If you have created these projects under an existing clone/repository, the NetBeans/Mercurial integration will already have a good idea of what to include or ignore.
NetBeans will automatically include files in nbproject that are considered to be environment independent. Files that include environmental dependencies (like directory paths) are usually placed in nbproject/private directory. You probably do not need to save those to your repo.
You may want to exclude the nbproject/build-impl.xml... it is generated when the project is opened... But, if you do not have it in your repo you will run into problems if you attempt to build the project with ant, independent of the IDE.
Anything that can be generated from what you check in should not be in the repository: no .class, .war, generated .jar, etc.

Categories