Skip to content
Advertisement

Tag: java

how to log only one level with log4j2?

I’m using log4j2 in my application. What I want is everything up to ‘debug’ to go to console, everything up to ‘info’ to go to myapp.log, and ONLY ‘info’ to go to ‘myapp-audit.log’. The reason is, INFO mostly consists of successful modifications to data (ex. ‘user created’, ‘user updated’, ‘user deleted’, and so on). If is effectively an audit log

Creating threads without extends and implements

I was going through an old project (Java) in my company where I found the author (already left), creates and runs thread without extending the Thread class or implementing the Runnable interface. One noticable thing was that the class was a singleton class. There are no usage of thread pooling, or the new concurrent package from java. Code snippet outlines

onNewIntent in Fragments in android

I am trying to develop a NFC application. I need to recognize the NFC TAG from the OnNewIntent that in the Activity class. Now I need to move and use fragments and not activity. Is their a way to replace the onNewIntent in the fragment class? Answer According to here (https://stackoverflow.com/a/5320694/3736955), you cant catch NFC intent by BroadcastReceiver. The only

SSL Java java.io.IOException: Invalid keystore format

I am testing SSL in java with SSLServerSocket and other classes in the java.ssl package. When I run the following code, I get the exception java.io.IOException: Invalid keystore format. My code: File key.txt: 1268312345812304612348712634283427346 I am guessing I should put something else in the key.txt file, but I do not know what to put in it. Probably a searilized object.

Swing application menu name not displaying correctly in Java 1.8

Okay, so I’ve done Swing applications before, and I know if you want to display a different name for the application menu (the one on Macs that usually have a “Preferences” and “Quit” option), you have to use: System.setProperty(“com.apple.mrj.application.apple.menu.about.name”, “App name”); and it must be executed before the JFrame is created. I’ve done this, but it continues to show my

Spring Boot with container security

I’ve been using spring boot for some projects lately and I really like it. For a new project, we’d like to use tomcat-users.xml for really basic authentication, but I can’t figure out how to use the mechanism without a web.xml file. Most people using spring boot seem to be using spring security. Is it possible to use tomcat container security

Calculate the date of Easter Sunday

Write a program to compute the date of Easter Sunday. Easter Sunday is the first Sunday after the first full moon of spring. Use the algorithm invented by the mathematician Carl Friedrich Gauss in 1800: Let y be the year (such as 1800 or 2001) Divide y by 19 and call the remainder a. Ignore the quotient. Divide y by

Maven child module does not exist

I’m new to Maven. I checked out from SVN a project from a customer with the following structure: the pom.xml right below ‘projectName` (the pom at the top) is building the three modules But when executing mvn clean install from folder projectNameit gives the following error The question is: Should there be a pom.xml right below projectName-warjust like with the

How to Change programmatically Edittext Cursor Color in android?

In android we can change the cursor color via: android:textCursorDrawable=”@drawable/black_color_cursor”. How can we do this dynamically? In my case I have set cursor drawable to white, but i need to change black How to do ? Answer Using some reflection did the trick for me Java: XML: Here is a method that you can use that doesn’t need an XML:

Advertisement