We are five students in a team and we must work in the same project using git.
What i did is:
create an empty project
add gitignore file
The gitignore file
contains:
*.class
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml
git init
git add .
git commit -m "Initial commit"
set up the remote and push
But we have a conflict in nbproject/private/private.properties file.
This file contains:
user.properties.file=C:\\Users\\Houssem\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
user.properties.file=C:\\Users\\ASUS\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
One of us he had cloned the repository and he can't add any java class in his local project.
You have confirmed in a comment that the output of git ls-files | grep nbproject/private/ contains line.nbproject/private/private.properties.
That means the file line.nbproject/private/private.properties is part of the repository.
You need to remove the file with git rm line.nbproject/private/private.properties,
and then commit the changes.
After that none of your collaborators should get any conflicts on this file.
Having nbproject/private/ in the .gitignore file should normally prevent line.nbproject/private/private.properties from getting added to the repository.
But it's possible that the file was added to the repository before .gitignore was created,
or that one of the collaborators force-added it (git add -f ...).
If possible, you might want to set up NetBeans to keep the project workspace (I believe this is called "Project" in NetBeans) outside of the actual repository and code, since this contains absolute references and (I'm assuming here) personal preferences.
I have no experience with NetBeans, but in Eclipse this works just fine.
Keeping the workspace files separate should also allow each developer to use an editor of his or her choice instead of being locked to one.
I have a dynamic web project in eclipse (although I'm not using it as a web project. I would like to convert it to a java project if possible) and there are java files all over the place. There are also a lot of other files like images etc (which I don't want to remove because the project is linked to my SVN repo so if i do an update then everything will come back).
Now when i build my project eclipse copies all the files instead of compiling and copying the .java files only and this takes a lot of time because there are some 2GB worth of files.
I tried to include only .java files in the source by going to properties of my project -> Java Build Path -> source tab -> includes -> I added "*.java" to the textbox. However, no file got copied to my output folder after that.
how do i go about this? Deleting the images etc from my project is not a solution here.
Add **/*.java/ in the includes.
So i downloaded Spring Jars from this link and I am trying to unzip the file, it keeps on complaining that some of the total path and file must not exceed 260 chars and it breaks from unzipping. How to download the jars and include them in my eclipse installation for working on my web projects, although this may seem trivial for some people it is very annoying to get around as i am new this kind of stuff. Really appreciate your help.
Thanks,
SS
Did you just unzip the zip file or the jar files? Just unzip the zip file, copy the jars in a lib folder in your project and add the jars to the buildpath of your project (Right click on the project -> Properties -> Java Build path -> Libraries -> Add jars).
And don't use the unzip functionality included in Windows, use an external program like 7zip. Then that error shouldn't occur.
You shouldn't need to unzip or unjar JAR files to use them in Eclipse. In fact, I'd recommend NOT doing this ... especially on Windows ... because it is liable to increase the amount of disk I/O.
But if you do want / need to do this, the jar command that is part of a Java JDK installation will be able to cope with them.
What you got was the correct ZIP . Now try to unzip it in something like c:\Spring instead of a nested folder like C:\Users\abcuser\Downloads\Spring\Spring Framework Notice the size difference between file paths.
To add jars to your eclipse project -
Right click project
Click "Build path" -> Configure Build Path... -> Libraries Tab
Click add external jar and select your jar
I'm running a simple Java program from the IntelliJ IDE using the Run->Run menu. It works fine. Now I want to add log4j logging.
I added a resources folder under my project root.
I added a log4j.properties file in that folder.
I changed the code to log something.
What is the right way to tell IntelliJ to include the resources folder in the classpath so the properties file is seen?
With IntelliJ 8 I could guess like a drunk monkey and eventually get it to work. I have 9 now and I am wholly unsuccessful. I've been trying for an hour. How about an "Add to classpath" option somewhere? /fume /vent /rant
Try this:
Go to Project Structure.
Select your module.
Find the folder in the tree on the right and select it.
Click the Sources button above that tree (with the blue folder) to make that folder a sources folder.
Actually, you have at least 2 ways to do it, the first way is described by ColinD, you just configure the "resources" folder as Sources folder in IDEA. If the Resource Patterns contains the extension of your resource, then it will be copied to the output directory when you Make the project and output directory is automatically a classpath of your application.
Another common way is to add the "resources" folder to the classpath directly. Go to Project Structure | Modules | Your Module | Dependencies, click Add, Single-Entry Module Library, specify the path to the "resources" folder.
Yet another solution would be to put the log4j.properties file directly under the Source root of your project (in the default package directory). It's the same as the first way except you don't need to add another Source root in the Module Paths settings, the file will be copied to the output directory on Make.
If you want to test with different log4j configurations, it may be easier to specify a custom configuration file directly in the Run/Debug configuration, VM parameters filed like:
-Dlog4j.configuration=file:/c:/log4j.properties.
I have the same problem and it annoys me tremendously!!
I have always thought I was surposed to do as answer 2. That used to work in Intellij 9 (now using 10).
However I figured out that by adding these line to my maven pom file helps:
<build>
...
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
...
</build>
I spent quite a lot of time figuring out how to do this in Intellij 13x. I apparently never added the properties files to the artifacts that required them, which is a separate step in Intellij. The setup below also works when you have a properties file that is shared by multiple modules.
Go to your project setup (CTRL + ALT + SHIFT + S)
In the list, select the module that you want to add one or more properties files to.
On the right, select the Dependencies tab.
Click the green plus and select "Jars or directories".
Now select the folder that contains the property file(s). (I haven't tried including an individual file)
Intellij will now ask you what the "category" of the selected file is. Choose "classes" (even though they are not).
Now you must add the properties files to the artifact. Intellij will give you the shortcut shown below. It will show errors in the red part at the bottom and a 'red lightbulb' that when clicked shows you an option to add the files to the artifact. You can also go to the 'artifacts' section and add the files to the artifacts manually.
Faced a similar challenge adding files with .ini extensions to the classpath. Found this answer, which is to add it to Preferences -> Compiler -> Resource Patterns -> [...] ;*.ini
If you ever end up with the same problem with Scala and SBT:
Go to Project Structure. The shortcut is (CTRL + ALT + SHIFT + S)
On the far left list, choose Project Settings > Modules
On the module list right of that, select the module of your project name (without the build) and choose the sources tab
In middle, expand the folder that the root of your project for me that's /home/<username>/IdeaProjects/<projectName>
Look at the Content Root section on the right side, the red paths are directories that you haven't made. You'll want to put the properties file in a Resources directory. So I created src/main/resources and put log4j.properties in it. I believe you can also modify the Content Root to put it wherever you want (I didn't do this).
I ran my code with a SBT configuration and it found my log4j.properties file.
For those of you who migrate from Eclipse to IntelliJ or the other way around here is a tip when working with property files or other resource files.
Its maddening (cost my a whole evening to find out) but both IDE's work quite different when it comes to looking for resource/propertty files when you want to run locally from your IDE or during debugging. (Packaging to a .jar is also quite different, but thats documented better.)
Suppose you have a relative path referral like this in your code:
new FileInputStream("xxxx.properties");
(which is convenient if you work with env specific .properties files which you don't want to package along with your JAR)
INTELLIJ
(I use 13.1 , but could be valid for more versions)
The file xxxx.properties needs to be at the PARENT dir of the project ROOT in order to be picked up at runtime like this in IntelliJ. (The project ROOT is where the /src folder resides in)
ECLIPSE
Eclipse is just happy when the xxxx.properties file is at the project ROOT itself.
So IntelliJ expects .properties file to be 1 level higher then Eclipse when it is referenced like this !!
This also affects the way you have to execute your code when you have this same line of code ( new FileInputStream("xxxx.properties"); ) in your exported .jar.
When you want to be agile and don't want to package the .properties file with your jar you'll have to execute the jar like below in order to reference the .properties file correctly from the command line:
INTELLIJ EXPORTED JAR
java -cp "/path/to_properties_file/:/path/to_jar/some.jar" com.bla.blabla.ClassContainingMainMethod
ECLIPSE EXPORTED JAR
java -jar some.jar
where the Eclipse exported executable jar will just expect the referenced .properties file to be on the same location as where the .jar file is
Right-click on your directory and from Mark directory as select Resources root as below:
Perhaps this is a bit off-topic, seeing as the question has already been answered, but I have experienced a similar problem. In my case only some of the unit test resources were copied to the output folder upon compilation. My persistence.xml in the META-INF folder got copied but nothing else.
In the end I "solved" the problem by renaming the problematic files, rebuiling the project and then changing the file names back to the original ones. Do not ask me why this worked but it did. My best guess is that, somehow, my IntelliJ project had gotten a bit out of sync with the file system and the renaming operation triggered some kind of internal "resource rescan".
This is one of the dumb mistakes I've done. I spent a lot of time trying to debug this problem and tried all the responses posted above, but in the end, it was one of my many dumb mistakes.
I was using org.apache.logging.log4j.Logger (:fml:) whereas I should have used org.apache.log4j.Logger. Using this correct logger saved my evening.
I had a similar problem with a log4j.xml file for a unit test, did all of the above. But figured out it was because I was only re-running a failed test....if I re-run the entire test class the correct file is picked up. This is under Intelli-j 9.0.4
I'm developing a Java application using Eclipse. My project has two source directories that are both built and then some files are copied into the output folder. From the output directory I then run my application and all works well.
However, I keep having these warnings:
Snapshot from Problems tab in Eclipse http://www.freeimagehosting.net/uploads/128c1af93f.png
Anyone know how to get rid of these warnings? Maybe by excluding some files, maybe based on the .svn extension or filename, from the build process? If so, how would I go about excluding those?
Have you tried to add
**/.svn/
to the Exclusion patterns at the Source preferences of the project's build path settings?
You could also try installing the Subversion plugin (Subclipse) for Eclipse.
Sure, that easy:
at Project Properties -- Java Build Path you can add exclusion filters on every source folder.
There, you can add an exclusion pattern as *.svn
That sounds like your building process is using versionned directory within your subversion workspace.
Should you not have your 'output' folder and/or your 'tst' folder be made 'private' ? (that is without any .svn, and ignored by subversion)
Right click on the source file > Build Path > Exclude.