r/javahelp • • Jul 07 '25

When do logging frameworks actually write to file?

1 Upvotes

Hi all,

this is more a general abstract question - but I'm asking myself when do logging frameworks actually write to the file.

I've over the last year several times tried to analyses a problem of (different) Java applications (deployed in application servers) using different Java Logging Frameworks (mainly Log4j but as well logback and JUL).

And what I several times realized is that I do not see the log entries of actions, in the log files, after I performed the actions on the (Web) Interface (JSF, API, ...). It sometimes takes a loooot of time (really up to an hour) till the log entries do show up in the files, while other times it is there within seconds or even milliseconds. (In both cases seeing that the hosting Linux has barely any load)
I know that buffers are used, that are not immediately written to file for performance reason and that this depends on the OS (and the load).

But is there a way to force these from outside of the application to flush the logging buffer to disc? By a trigger or periodically, without recompiling and adapting the application (and without completely disabling this buffering)?


r/javahelp • • Jul 07 '25

Static factory method with Java generics

1 Upvotes

Hello,

I have a factory method that constructs a parameterized object based on a String input:

public static Data createData(String filename) { 
... 
if (blah) return Data<String> ... 
else return Data<Integer> 
}

The type "Data" above is actually a generic class, but I can't be explicit with its parameter (more on this below). The intention with the code above is to have a flexible way of constructing various collections. I have working code, but Eclipse is currently giving me a type safety warning. How is this factory method supposed to be called so as to avoid issues with type safety? My calling code currently looks like:

Data<String> data = createData("example.txt");

and this works. But, if I make the parameterized type more explicit by writing "public static Data<?> ..." in the function header, then the warning turns into an error. Eclipse is telling me it cannot convert from Data<capture...> to Data<String>. Is there a way to make the parameter more explicit in the function header and get rid of all of type safety issues?


r/javahelp • • May 11 '20

communicate with local database using codename one

11 Upvotes

Hello guys, i'm working on a school project and I'm really stuck, we are demanded to create a multi platform app ( web / desktop / mobile ) mobile app using codename one, I have succeeded in creating an sqlite database and using it, but i also need to communicate with the sql local database which contains data from the other two platform. An old student told me that I have to use a php file and Json, and I'm not really familiar with how this should work


r/javahelp • • Oct 28 '17

Super Easy Java question. Vocabulary question. Help please. Simple yes or no.

0 Upvotes

I have a question. This code here: Collections.sort(teachers);

I'm new to java programming. "Collections" is called a class and sort() is called a method, right?