What is the directory architecture of any project in netbeans - netbeans

By default following directories are created in netbeans:
nbproject
src
build
manifest.mf
Suppose I want to add image and database directory to store images and database. Should these directories be under src? Let me know what is the correct directory architecture of any project in netbeans ?

Thats a too philosophical question under developers. Be more specific for which kind of project.
For web i reccomend something like this:
Src - all your own code
Libraries - all external code
Public - mostly url reachable files and htaccess
Assets - images, media
Styles - the name says it
In your case i would add another folder database

Related

NetBeans, html5 project. What is the difference between Site Root Folder and Source Folder?

Always I store an all my front-end sources in Site Root Folder.
But today I update netbeans to 8.1 and I notice the Source Folder in the project properties.
What this folder for?
It is good explained in NetBeans Help -> Project Properties Window: Sources
Site Root Folder
The contents of this folder will be available through the web server on the production site. It contains the HTML, CSS and JS files that are publicly accessible/visible. This folder typically contains the index.html file.
Source Folder
The folder in the project that serves for server-side sources (typically node.js JS files). If the project is a JS library, JavaScript files should be placed in this folder (not in the Site Root Folder).
When you use Grunt or Gulp you should store sources and final site and different folders.

JavaFX FXML 2.2 - Deploy Application with bitmaps

I have searched a lot and tried several ways to do this, but am stumped. I am writing a desktop app (though I suppose it could also run in a browser) that allows an Android programmer to edit all of their dimens.xml files at once. I have created my own images to use in ImageViews as buttons. I am using different methods to access these images:
Some are referenced in the FXML file, like <Image url="#Icons/ic_launcher.png" />. The path is "src/Icons/". The path of the FXML file is "src/application/xxx,fxml".
Some are referenced in the css file, like "-fx-image:url("QuestionMark.png");". The css file and png file are in the same directory "src/MessageBox/"
Some are changed dynamically at runtime:
ImageView mButtonIcon = new ImageView("/insert_item_above.png");
The path of the image: src/
The path of the class: src/ContextMenuButton/
The above only works in Netbeans 7.4. None work when I run the app in Eclipse.
If I go to the dist/ directory and run it from any of the 3 methods, I see my images.
If I move the dist/ folder somewhere else, the only way I can get it to work is if I copy the src/ folder to the same directory and delete everything but the png and css files. So, I end up with:
+ F:/AndroidDimens
+ dist
xxx.jar
+ src
insert_item_above.png
+ Icons
ic_launcher.png
+ MessageBox
QuestionMark.png
So, the jar file has modified all of the paths to be relative to the src/ folder. My goal is to make the paths relative to where the jar file is. I tried to place the images where I would not need project related paths. But it must have made the paths something like "../src/MessageBox/QuestionMark.png" in the jar (relative to the project's dist/ folder).
Is there any way to fix this? Ideally, I would like all images to be in one directory. Then I could zip that directory, and someone else could just unzip it and run the app.
Thanks!
EDIT
Thanks to #jewelsea (in chat), I found that the problem was due to having an older version of JDK 7u13 installed with the latest one needed for JavaFX 2.2. Deleting the old version, and updating global variables that referenced it, solved the problem. No changes were needed to the default project settings.
Packaging Advice
Package all of your application's runtime class files and resources (fxml, css, png, etc) in the application jar file using the JavaFX packaging tools.
Using the JavaFX packaging tools is what NetBeans 7.4 does automatically during it's build process for JavaFX application projects.
Eclipse and other build environments will not use the JavaFX packaging tools automatically. I believe, if you use Eclipse with the recommended e(fx)clipse extension toolset for JavaFX development, then that toolset will, through its UI, provide you with the ability to use the JavaFX packaging tools to package your application.
There are 3rd party packaging alternatives for JavaFX such as the JavaFX Maven Plugin or the JavaFX Gradle Plugin which will also package your application correctly.
Whatever packaging tool you choose, test the packaging process by unzipping the files from your resultant jar and checking that all of the resource files (fxml, css, png, properties etc) are where you expect them to be in the jar's internal directory structure. This unzipping process is just a developer sanity check, you don't need to ask your end users do perform such an extraction.
Your end users can run your application as either an installed native application (JavaFX term self-contained application) or as a click to execute jar file (JavaFX term standalone program) and all of your application's resources will automatically be available from the packaged application, with no additional work required by the user.
Resource Access Advice
I advise not referring to a src path in your code (as you won't have a src path inside your distribution jar), css or fxml files, but instead refer to those paths relative to the root of the distribution jar or your JavaFX application class. For example, to load a scene style sheet in a JavaFX Application subclass, use a form as recommended by the JavaFX deployment guide - 3.3.4 Loading Resources:
scene.getStylesheets().
add(this.getClass().getResource("my.css").toExternalForm());

eclipse dynamic web project file locations

I'm creating a new dynamic web project in Eclipse and was wondering what best practices are for folder taxonomy. Here's what I believe it is <> are folders. Can someone please verify?
<Eclipse project name>
<src>
-- .java files
<WebContent>
-- .html pages
<images>
<css>
<js>
<META-INF>
MANIFEST.MF
<WEB-INF>
web.xml
<app name>
-- .jsp pages
Here is a sample folder structure of a dynamic web project:
As you can see all static files are placed as sub-folders under the WebContent folder. By naming conventions .css files are places in the css sub-folder. JavaScript .js files are placed under the js sub-folder and any image files such as .jpeg or .png are placed in the images sub-folder. I also have an extra lib sub-folder where I placed an angularjs library to be used.
By default after creation of a dynamic web project your web.xml file looks like so:
`<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>`
meaning it will first call the listed default name files when you run your application. This is why most projects will name the files as index.html or index.jsp. NOTE: that my index.html file is directly below the WebContent folder and not in a sub-folder
Finally you can call/include your static files (.css .js and image files) from your 'index' file like so:
<link rel="stylesheet" href=css/bootstrap.min.css>
<link rel="stylesheet" href=css/bootstrap-theme.min.css>
<script type="text/javascript" src="lib/angular.min.js"></script>
<script src="js/contactsApp.js"></script>
Also your .java files will properly go in the Java Resources -> src -> {place java files here}
Put your pages under WEB-INF folder, in that way they cannot be accessed directly.
Also look at maven directory layout http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html.
To what Aleksandr M said,
WebContent folder:
The mandatory location of all web resources, including HTML, JSP, graphic files, and so on. If the files are not placed in this directory(or in a sub directory structure under this directory), the files will not be available when the application is executed on the server.
WEB-INF
Based on the Sun Microsystems Java Servlet 2.3 Specification, this directory contains the supporting Web resources for a Web application, including the web.xml file and the classes and lib directories.
Source: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.wst.webtools.doc.user%2Ftopics%2Fccwebprj.html
I am not sure why having an app-name directory under WebContent would be considered a "best practice".
Other than that, one primary rule you should be following when coming up with a directory structure is to have all static resources under one directory. In your example, I would have a subdirectory called static under WebContent, and place the js, css and images directories under it.
That way, it'd be easier for you to (later on) configure your HTTP server to pick static resources directly from the file system rather than route requests for static resources through the servlet container.
I had this question too and can't comment yet, but Upendra Bittu's answer helped me.
http://help.eclipse.org/neon/index.jsp
Search 'jsp', click on "Creating JavaServer Pages (JSP) files"
Create a dynamic Web project if you have not already done so.
In the Project Explorer, expand your project and right click on your WebContent folder or on a subfolder under WebContent. Note that
if you choose any other folder in which to create the JSP, then it
will not be included in the WAR file that is deployed to the server.
In addition, link validation will not encompass files that are not
under the WebContent folder.
From the context menu, select New > JSP. The New Java Server Page window appears with your folder selected
I'm trying out tutorials and get lost when people don't say where they create their files, and this helped me understand what's going on, so I'm just passing it on.

How to set reference to the folder which contains multiple jar files?

My environment:
Netbean 6.9.1
Glassfish 3.0.1
Windows 7
Goal:
When my coworkers opens the Netbean Project, the library is already referenced without them manually create library, adding jars into it and reference it.
Detail:
I created Netbean project and the project has reference to few jar files in the folder.
Currently whoever opens the project for the first time, they have to manually create library and refer it to the project.
My project location:
C:\Users\masatosan\Desktop\myProject\myApp
My library location:
C:\Users\masatosan\Desktop\myProject\lib\myLib
The myLib folder contains:
some1.jar
some2.jar
some3.jar
I can achieve my goal if I create reference to individual jar file by defining to project.properties file like below: (creating reference to sqljdbc4.jar)
file.reference.sqljdbc4.jar=../lib/sqljdbc4.jar
javac.classpath=\
${libs.restlib_gfv3ee6.classpath}:\
${file.reference.sqljdbc4.jar}:
But my case is different since I have 3 jars in the myLib folder and wanting to reference them all.
Is it possible to reference all jars in myLib folder?
Please let me know if you need more clarification.
I'm sorry, but it doesn't work that way. When you create a project, you have to add the jar files individually.
However, if you put your lib folder under your project, netbeans will refer to them via relative paths. Then when you share the project (lib directory included), netbeans will be able to automatically find the jar files when the next person uses the project. That way you only have to add jar files once.
Short of using a dependency management tool like maven (which Netbeans has good support for), this is really the best solution. It uses a bit more disk space (obviously), but that's never been a huge issue for me.
I figured how so let me share.
Tool --> Library then library window pop up.
Create library called "MyLib" which contains multiple jars.
Add "MyLib" to your project. This change will be written to project.properties file under nbproject folder.
project.properties file indicates the classpath of lib reference you just added.
It should look like something below
javac.classpath=\
${libs.Excella.classpath}:\
${libs.MyLib.classpath}
Now someone else opens the project from different machine and she just needs to do step#1 and #2, which is to create library with same library name i.e. "MyLib"
I think this is what Bill was saying originally but thought it would be helpful to give step by step instructions since I finally figured .... after long time :D

Eclipse is not creating structure for Enterprise Application Projects

When creating a New Enterprise Application Project, instead of creating the usual tree with:
+Deployment Descriptor
+JAX-WS WebServices
+ejbModule
+JRE System Library
+JBoss v5.1
+EAR Libraries
+JavaScript Resources
+build
Eclipse is creating only a very simple structure. Like This:
+JavaScript Resources
Only the .settings folder and .project file are being created in the project's folder. No source, etc.
What's going on with this?
Thanks
It sounds more like you're listing the contents of a View rather than what's actually in your project. There isn't actually a "JavaScript Resources" folder, it's a root node under which the project's known types and globals are browsable. Have you checked the Project Explorer view (Window->Show View)?