Stacktrace to string in Java
Easiest way to convert the result of Throwable.getStackTrace() to a string that depicts the stacktrace? ...
Easiest way to convert the result of Throwable.getStackTrace() to a string that depicts the stacktrace? ...
Is there any better way to cache up some very large objects, that can only be created once, and therefore need to be cached ? Currently, I have the following: public enum LargeObjectCache { INSTANCE; private Map<String, LargeObject> map = new HashMap<...>(); public LargeObject get(String s) { if (!map.contains...
I am running a webapp inside Webpshere Application Server 6.1. This webapp has a rules kind of engine, where every rule obtains its very own connection from the websphere data source pool. So, I see that when an use case is run, for 100 records of input, about 400-800 connections are obtained from the pool and released back to the pool. ...
Hi, could anyone please clarify the meaning of class libraries on the classpath in the case of Tomcat in the following line: Actually all classes used by the web-app(unless they're part of the class libraries on the classpath) must follow the same rules as servlet classes-inside WEB-INF/classes, in a directory structure matching the pa...
I'm looking for a java gui testing tool in which tests can be created by recording my gui actions (buttons pressed, windows closed, etc.) A scripting mechanism for writing tests is not required. It could be free or commercial, but cheap and great is better than expensive and great. My application is a rich-client app written in Java ...
My lucene index contains documents with the field "itemName". This field is boosted with a boost factor between 0 and 1. When i create a BooleanQuery i'd like that the results are ranked by the count of matched clauses and the boostfactor, so the formula looks like: score = (count_of_matching_clauses / count_of_total_clauses + boost_fac...
Hello, I am trying to create a directory in Java. I think I have provided correctly all necessary things so that I make the directory, but it is not created. You can see from my code below and the corresponding output that every element from which I compose the path of the new directory should be correct and valid. It seems, however, th...
I have a string: "hello good old world" and i want to upper case every first letter of every word, not the whole string with .toUpperCase(). Is there an existing java helper which does the job? ...
Hi every one I have these classe @Entity @Table(name = "login", uniqueConstraints={@UniqueConstraint(columnNames={"username_fk"})}) public class Login implements Serializable { @Id @Column(name = "id") @GeneratedValue private int id; @Column(name = "password", length = 64) private String password; @Column(na...
What is the difference between a synchronized method and synchronized block in Java ? I have been searching the answer on the Net, people seem to be so unsure about this one :-( My take would be there is no difference between the two, except that the synch block might be more localized in scope and hence the lock will be of lesser tim...
Consider this code: public <T> List<T> meth(List<?> type) { System.out.println(type); // 1 return new ArrayList<String>(); // 2 } It does not compile at line 2, saying that List is required. Now, if it's changed to: public <T> List<?> meth(List<T> type) { System.out.println(type); // 1 return new ArrayList<String>(); // ...
To my surprise in the following program the Eclipse console doesn't print while in the loop. It prints only: "start: finish". When I use println instead it does. Of when I remove the comment it does too. Surprise: when I copy the lines "start: finish" in the console, the clipboard does contain all printed numbers. Interesting to know wa...
I have a method that takes an array of queries, and I need to run them against different search engine Web API's, such as Google's or Yahoo's. To optimize this process, I thought of creating a thread for each query, and then joining them all at the end, since my application can only continue after I have the results of every query. My st...
I want to draw rectangle based on mousedrag event. if user dragging the mouse, then the rectangle on the applet should increase or decrease basing on current mouse coordinates. i have the following code. in the following code i am using SelectionArea class which extends a canvas on which i am performing drawing operation. i am using ima...
I'm doing some excercises with java (some of you may suppose where the code comes from). I try to provocate a deadlocksituation with the following code: class Resource { public Integer value = 42; } public class DeadLockRisk implements Runnable { private Resource resourceA = new Resource(); private Resource resourceB = ne...
Is it possible to implement a multi-threaded class loader in Java? In a meta-driven framework I need to load several hundreds of classes in advance, ie, not as lazily as the system classloader. In order to accelerate this, I would like to better utilize current multi-core CPUs. Before I dive into that, I would be interested if somebody a...
I would like to implement a thread pool in Java, which can dynamically resize itself based on the computational and I/O behavior of the tasks submitted to it. Practically, I want to achieve the same behavior as the new Thread Pool implementation in C# 4.0 Is there an implementation already or can I achieve this behavior by using mostl...
It is a little bit annoying to have the GWT hosted browser (on a Mac) pop up at always the same screen location and same size (that is: to small and at the wrong place!). In particular if you have two 24" monitors it couldn't be less annoying to always move the browser window and to resize it on startup. I know I could leave it open and ...
I am building a small GUI application where I use drag and drop internally on custom components. Now I want to have context menus on the components which have drag and drop enabled. Now my question is, how do I properly distinguish between these two events. For context menus there is an API function, but for DnD I did not find one. I us...
Hello, A server listens on a port, waiting for incoming requests from clients (the client as a matter of fact is an ejb). These requests pass a complete object model as parameter (e.g. a list of Employees, each Employee a list of Tasks etc.). Now the server has to start another java program in a new JVM instance on the same machine, w...