Maven dependency:analyze complains about the dependencies in my project. How does it determine which are unused and which are undeclared? What should I do about them? Example: Note: A lot of these dependencies are used in my runtime container and I declared them as provided to avoid having the same library on the classpath twice with different versions. Answer Not
Sharing Cookies Between Sub Domains in java?
I have some cookies stored in http://sub1.myserver.com and I want to be able to see them in http://myserver.com Answer I was able to do it using the following code:
Java conditional compilation: how to prevent code chunks from being compiled?
My project requires Java 1.6 for compilation and running. Now I have a requirement to make it working with Java 1.5 (from the marketing side). I want to replace method body (return type and arguments remain the same) to make it compiling with Java 1.5 without errors. Details: I have an utility class called OS which encapsulates all OS-specific things.
Checking if a date exists or not in Java
Is there any predefined class in Java such that, if I pass it a date it should return if it is a valid date or not? For example if I pass it 31st of February of some year, then it should return false, and if the date exists then it should return me true, for any date of any year.
Does Java IO have a maximum file name length limit?
Different operating systems have different file name max lengths. Does Java have any limit on file name length when working with files? Answer Java has no maximum file name length, except obviously for the String max length limit (which is the array max length, i.e. Integer.MAX_VALUE). Maybe some JVMs have a lower limit but I never run into such a
how to start stop tomcat server using CMD?
I set the path for the tomcat and set all variables like JAVA_HOME=C:Program Files (x86)Javajdk1.6.0_22 CATALINA_HOME=G:springworkserverapache-tomcat-6.0.29 CLASSPATH=G:springworkserverapache-tomcat-6.0.29libservlet-api.jar;G:springworkserverapache-tomcat-6.0.29libjsp-api.jar;.; When I go to bin folder and double click on startup.bat then my tomcat starts and when I double click on shutdown.bat tomcat stops. But I want using CMD start and stop the tomcat. And in any folder I write command startup.bat the
when is a spring bean instantiated
In the above, when are the beans instantiated, when the ApplicationContext is created or when the getBean() is called? Answer Assuming the bean is a singleton, and isn’t configured for lazy initialisation, then it’s created when the context is started up. getBean() just fishes it out. Lazy-init beans will only be initialised when first referenced, but this is not the
how to call getResouces() in a class that is not extended Activity?
I would like to call getResouces in some classes, however, these classes are not extended to Activity. How to do it in a right way? Answer You can pass in a pointer to your activity from which you should call getApplicationContext(). In certain cases you would want to use the regular getContext().
How can I add JAR files to the web-inf/lib folder in Eclipse?
I’m using Eclipse and I need to be able to add Java libraries (JAR files) into my web application’s WEB-INF/lib folder. How do I achieve this? Answer Add the jar file to your WEB-INF/lib folder. Right-click your project in Eclipse, and go to “Build Path > Configure Build Path” Add the “Web App Libraries” library This will ensure all WEB-INF/lib
How do I remove some characters from my String
i want to remove all of the following chars from my string “>[],-” at the moment im doing this. but there must be a more efficient way newString = myString.replace(“>”,””).replace(“[“,””)….