Netbeans: how do I change the name of a project? - java

I need to change the name of my application, so people who download and install it can see the name but I don't know where to do it.
What file do I need to edit?

you must right click on your project in Project window [ctrl + 1] and choose rename option for
renaming your project name.

if your project is mobile Project you must right click on project name , select properties options and then on Application Descriptor edit MIDlet-name value.

If you use gradle:
BuildScripts/Project/settings.gradle
rootProject.name = 'yourprojectname'

If your project is Maven based, you can either add/update the application name in pom.xml (found in Project Files folder) or go to File >> Project Properties and add/update the application name.

Open "project.xml" file under nbproject folder inside the project folder of the one you want to change the name.
it is in the tag <name>.
Just change it and that is it.

open project.properties in dir nbproject
look up to manifest.midlets and change the name after MIDlet

Rightclick on the project node and select rename.
If you want the folder of the project also to have the new name or whatever that wasnt renamd then :
1.in build.xml in text editor find old name and replace with new one. Its place is: C:\NBProjectsFolder\OldName\build.xml Save that.
2. Remove all cash situated in , e.g.: C:\NBProjectsFolder\OldName\build\gwt-unitCache.
3. Find in C:\NBProjectsFolder\OldName\nbproject\private private.xml file and edit it in a text redactor by renaming old name within the file. Save that.
Do all the changes when the Netbeans was closed.
After opening the Ntbeans it may ask to reimport the project and all files you changed will be recognized/recreated automatically

Related

Unable to use images in Intellij IDEA [duplicate]

I have a Java Project in NetBeans 7.0.
I want to add some image to some label dynamically. The image will differ depending on the state of the program.
I put one such image, 'filling.jpg', in the 'resources' folder of my project.
I want to reach this file correctly (not by absolute or relative path, because that will cause problems when I build the jar file).
So I found this method:
ImageIcon fillingIcon = new ImageIcon(getClass().getClassLoader().getResource("filling.jpg"));
labelFontFilling.setIcon(fillingIcon);
It keeps give me java.lang.NullPointerException.
But I am sure that there is that image, because I can assign the image to the label from the NetBeans Properties menu for that label (but I don't want this, I want to add the image by Java code).
What am I doing wrong, and how can I get that image correctly?
This was a pain, using netBeans IDE 7.2.
You need to remember that Netbeans cleans up the Build folder whenever you rebuild, so
Add a resource folder to the src folder:
(project)
src
project package folder (contains .java files)
resources (whatever name you want)
images (optional subfolders)
After the clean/build this structure is propogated into the Build folder:
(project)
build
classes
project package folder (contains generated .class files)
resources (your resources)
images (your optional subfolders)
To access the resources:
dlabel = new JLabel(new ImageIcon(getClass().getClassLoader().getResource("resources/images/logo.png")));
and:
if (common.readFile(getClass().getResourceAsStream("/resources/allwise.ini"), buf).equals("OK")) {
worked for me. Note that in one case there is a leading "/" and in the other there isn't.
So the root of the path to the resources is the "classes" folder within the build folder.
Double click on the executable jar file in the dist folder. The path to the resources still works.
I have a slightly different approach that might be useful/more beneficial to some.
Under your main project folder, create a resource folder. Your folder structure should look something like this.
Project Folder
build
dist
lib
nbproject
resources
src
Go to the properties of your project. You can do this by right clicking on your project in the Projects tab window and selecting Properties in the drop down menu.
Under categories on the left side, select Sources.
In Source Package Folders on the right side, add your resource folder using the Add Folder button. Once you click OK, you should see a Resources folder under your project.
You should now be able to pull resources using this line or similar approach:
MyClass.class.getResource("/main.jpg");
If you were to create a package called Images under the resources folder, you can retrieve the resource like this:
MyClass.class.getResource("/Images/main.jpg");
Thanks, Valter Henrique, with your tip i managed to realise, that i simply entered incorrect path to this image.
In one of my tries i use
String pathToImageSortBy = "resources/testDataIcons/filling.png";
ImageIcon SortByIcon = new ImageIcon(getClass().getClassLoader().getResource(pathToImageSortBy));
But correct way was use name of my project in path to resource
String pathToImageSortBy = "nameOfProject/resources/testDataIcons/filling.png";
ImageIcon SortByIcon = new ImageIcon(getClass().getClassLoader().getResource(pathToImageSortBy));
For me it worked like I had images in icons folder under src and I wrote below code.
new ImageIcon(getClass().getResource("/icons/rsz_measurment_01.png"));

stop eclipse from deleting folders inside "target"

I am developing a maven project with Spring mvc application with Eclipse. I have some cucumber-selenium test case to check the some behavior of app. I put the chromDriver.exe in the path target\classes\Driver.
When i want to run the application it complains about:
The project was not built due to "Could not delete '/CyberMall/target/classes/Driver'.". Fix the problem, then try refreshing this project and building it since it may be inconsistent CyberMall Unknown Java Problem
It seems that, it tries to delete the Driver folder inside the target, and it fails, so it cannot build the application.
So, is there any way to ask Eclipse to stop deleting the Driver folder?
The reason I have put the driver in this path is that, i can easily access to it using the below code.
File file = new File(CyberMallApplication.class.getClassLoader().getResource("Driver/chromedriver.exe").getFile());
String driverPath=file.getAbsolutePath();
System.out.println(driverPath);
System.setProperty("webdriver.chrome.driver",driverPath);
If i put it into the resources, i don't know how to access it?
I think it's not a good practice to put a file that should be used in the targer folder.
The target folder should be clean at every maven install so the content is deleted.
You can put your file in the resources folder insted.
Take a look at that link : https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
The target directory is used to house all output of the build.
The content of the resource directory will be put inside WEB-INF/classes. So you can adapt your resources folder to have your folders like you already have.
resources/Driver/chromedriver.exe
You should put chromedriver.exe to src/main/resources and set relative path in the system properties
System.setProperty("webdriver.chrome.driver", "src/main/resources/chromedriver.exe");

Generated source files should not be edited?

When I create this new class Quake and try to write some code in it ,it displays the following message,
and when I try to run it Android Studio automatically delete the class Quake.
Can someone explain me why is this happening and how to resolve it ?
You're in Packages view and putting all your files in the wrong folder. Switch to Project view (left hand, top side toggle). Under app, you should see a folder called src -> main -> java -> com.example.prateek. That's where all your class files should properly be to avoid autodeletion.
This happens due to incorrect Source folder mappings done by some mistake.
In order to resolve the same, please go to
Project Structure -> Project Settings -> Modules.
Select the Module that has this issue and select the Sources Tab
On the Right Hand Side you will find Add Content Root pane. Please Check if the Source and Test Folders are mapping to the correct root and there is no other mapping present apart from the valid root mapping [For eg src for Source Folders and tst for Test Source Folders.]
Delete any unwanted mapping present in either of them. Apply and Re sync the project.
Issue should be solved now.

How to add resource file to JAR in IntelliJ

I am using IntelliJ IDEA 14 and I want to add file outside of src to the JAR file. This is my current project structure.
I want to add layout.txt and saveddata.txt to the JAR file executable. I've been googling on that for a while can't find the solution
In case you need to see my code. This is how I am reading file
private Path layoutPath = Paths.get("resources/layout.txt");
content = new String(Files.readAllBytes(layoutPath));
Here is my project structure
Create a folder called "resources" at the same level as "src"
Right click the folder, select "Mark Directory As -> Resources Root"
Make new directory with name as "resources" under your project root directory.
Right click on that directory and select "Mark Directory As" ==>"Resources Root" option.
It's still for me. I tried:
+ "Mark Directory As" ==>"Resources Root"
+ getClassLoader().getResourceAsStream()
+ getClass().getClassLoader().getResource()
and Thread.currentThread().getContextClassLoader().getResourceAsStream()
For me, the resources directory was already marked as Resources Root but the content was missing in the jar. I had to manually add the resources dir to the jar artifact using the Project Structure window.
Open Project Structures window
Select Artifacts and click on the + button and then select Directory Content
Choose resources directory
Press Apply then OK

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")...

Categories