I keep on getting the same error, I have already changed the tomcat7w file that specifies the jaas config file location I have already added this tom my tomcat7w.exe file. another is that I also have this realm so what am I missing? please help me, I am using netbeans, tomcat 7.0.47. I have resolved to using …
Tag: java
Why is my Spring @Autowired field null?
Note: This is intended to be a canonical answer for a common problem. I have a Spring @Service class (MileageFeeCalculator) that has an @Autowired field (rateService), but the field is null when I try to use it. The logs show that both the MileageFeeCalculator bean and the MileageRateService bean are being cr…
Print Java enum to lower case by default keeping enum constants in uppercase
I have an enum in Java I’d like to serialize, so that when I call it from anywhere in the code, I get the lowercase representation of the name. Let’s say I have the following enum: I’d like to get the following: [Note]: I want to use the enum constants in uppercase, and when requesting the v…
java.io.FileNotFoundException: the system cannot find the file specified
I have a file named “word.txt”. It is in the same directory as my java file. But when I try to access it in the following code this file not found error occurs: Here’s my code: Answer Put the word.txt directly as a child of the project root folder and a peer of src Disclaimer: I’d like…
Can you invert a switch in java?
Is there a way to invert a switch for example switch (!(x))? I’m writing a program and I only want the user to be able to input certain letters. If they input an invalid letter, they would have to input it again. I’m trying to use a switch for this avoiding doing something like because the number …
Java read file and store text in an array
I know how to read a file with Java using Scanner and File IOException, but the only thing I don’t know is how to store the text in the files as an array. Here is a snippet of my code: Here is what my KeyWestTemp.txt file contains: Answer Stored as strings: For floats:
Why does my ArrayList contain N copies of the last item added to the list?
I’m adding three different objects to an ArrayList, but the list contains three copies of the last object I added. For example: Expected: Actual: What mistake have I made? Note: this is designed to be a canonical Q&A for the numerous similar issues that arise on this site. Answer This problem has tw…
How to keep a variable value even after doing run as-> Java Application?
I know that when we use static variables the value remains the same for all the instances of a class. But when I do run as -> Java Application in a class, even the static variable is reinicialized with the default value. Is there any way to keep a variable value even after doing run as-> Java Applicatio…
How to retrieve my public and private key from the keystore we created
My task is the following: Retrieve my public and private key from the keystore I created. Use these keys to encrypt a paragraph using my RSA 2048-bit public key. Digitally sign the result using the DSA-SHA-1 signature algorithm. Save the digital signature output on a file called output.dat. The program below …
Is it bad practice to keep data in static variables?
In an Android application, is it bad practice to store objects in static fields in these cases? Application data. Is it bad to keep application data in static variables in a class while the application is running? Currently, I’m storing the data in an instance variable in my Application class. Then clas…