How to make properties file in netbeans - java

i am working on a struts2 web application-project and using netbeans 6.9. i want to create a properties file for my project.
how do i do that in net-beans........

right click on the location where you would like to add property file.
new > other > other > Properties file

Related

Enable content assist for *.properties in Eclipse STS

I have STS 4.4.0.RELEASE installed in my computer which is directly downloaded from spring.io
Content assist works fine for application.properties but does not work for bootstrap.properties. I have enabled file associations to open *.properties with "Generic Editor - Spring Properties". But still there is no content assist.
Any pointers?
Go to: Preferences > General > Content Types > Text and select Spring Properties File.
Now click on Add in File associations, add the content type accordingly (in my case it was *.properties) and click on OK.

How to add classes folder in web-inf in eclipse

I am new to struts. So in eclipse I don't have web-inf->classes, where I should put my struts.xml.In other project I have done this by
project->properties->java build path->output folder->browse(webcontent->web-inf->classes)->create folder(classes)->advanced->apply.
But now it is not working .the struts.xml file is now created in java resources->libraries->web app libraries.
Please see the image:
While deploying struts project struts.xml need to bee kept in web inf folder not in classes folder that is in web app folder .Once you copied your struts.xml file in web inf folder refresh your project by right click on project.
Else you can create a new dynamic web project and copy all your files[![enter image description here][2]][2]
Eclipse offers the Navigator view which will display your project in the way you are asking. To open this view select Window > Show View > Navigator. then you can see where is your struts.xml if path is not correct check it.

Android load & read properties file in library project

I have android & rest webservice api binary project
OnlineCourse
src
res
lib
manifest.xml
CourseAPI
src
config.properties
build.xml
Android project right click -> property -> java build path -> project ->Add select CourseAPI project. That all i did.
My problem is courseAPI project contain property file & java file read values.When I run only courseAPi project working file , read property file.
But when I run the android project, that binary java file couldn't read file. It say FileNotFoundException
Please guide me what is an issue
To read the properties file, you have to put the properties file in main project.

How to access files from your source folder, eclipse

In my project on eclipse I created another source folder to hold an mp3 file. Does anyone know how to access that file. What would the file path be? The reason why I did this is so this file would be included with my project when I turn it into a jar file and run it on different computers. If anyone has a better idea on how to do this feel free to contribute!
right click on your project > properties > resources > location
if you want to programmatically go there generally eclipse starts jvm with working directory set to base of project so you can navigate from new File(".")
Check the getResourceAsStream method from class Class: http://www.tutorialspoint.com/java/lang/class_getresourceasstream.htm
In spring:
ResourceLoader resourceLoader;
final Resource resource =
resourceLoader.getResource("classpath:com/XX/XX/" + filename);
in Eclipse, right-click on your project and select "Properties".
With "Resource" selected, it shows "Location:" which is the path to your project.
Let's say if you added a folder to your project called Audio, then you could access a mp file like this:
new File(".\\Audio\\MyAudioFile.mp3")...

How to add properties file into Java project?

I am using .properties file for my project and Netbeans 6.9.1 IDE. How can I add my properties file into the code?
String prop="c:\\Config.properties";
Properties Config= new Properties();
Config.load(new FileInputStream(prop));
f1=Config.getProperty("f1");
f2=Config.getProperty("f2");
How can I define my Build path instead of "c:\\Config.properties"?
Is there any way to add this file directly to the project?
You could put the config.properties into one of your packages and then define the path to your properties file relative.
ClassLoader.getResourceAsStream ("your/app/package/config.properties");
Niraj,
Do not use the hardcoded path for your properties file. Either get the file path from the project properties or using the build/runtime values.
Hope this will help: Adding properties

Categories