java

Is it possible to have architecture guidelines? If so what should be in them?

In the same way we have coding standards, can there be things such as architecture standards? These would be high level principals that we can pass to our less experienced programmers so when they start designing changes or small applications they know what we expect to see without the more experienced programmers having to correct them...

Should I use PHP or JSP for a chat website?

I want to develop a website web chat application like yahoo. Only difference is that I want to make it web based not desktop. I will be implementing it in jsp/php with ajax. I want to know whether jsp or php will be better for this. What will be advantages or disadvantages of both. Which one of the two would you prefer and why? Will js...

How to debug/log/trace an applet loading problem?

Recently two of our clients have reported problems with our applets. Looking at the java plugin console it is full of ClassNotFoundException so none of our code is executed. I've been able to reproduce the stack trace using a virtual pc image with 0 free space on disk, but the problem goes away as I restore some disk space, and the user...

Using Java Generics with Enums

Update: Thanks for everyone who helped out - the answer to this one lay in what I wasn't noticing in my more complex code and what I didn't know about the Java5 covariant return types. Original Post: I've been playing around with something this morning. While I know that I could tackle this whole problem differently, I'm finding mysel...

Monitor a HTTPS connection with URL class (Java)

I would like to monitor a simple url. But when its a https server I get a handshake exception. Its possible to verify state of a https url the way browser use to connect? (without having a local certificate). I don't know how browsers do to get content from a https url but I would like to make it the same way. Without need to store a spe...

Randomness in Jython

When using (pseudo) random numbers in Jython, would it be more efficient to use the Python random module or Java's random class? ...

Can Tangosol Coherence cache non-serializable objects?

I'm using Tangosol Coherence v3.2.2b371. Can I cache objects that do not implement Serializable through the NamedCache api? Or this depends on configuration? Edit: For clarification, I'm trying to cache compiled javax.xml.xpath.XPathExpression objects. ...

J2EE Filters not able to get cookies?

Why aren't cookies able to be referenced from a servlet filter? It just seems beyond me that J2EE wouldn't allow you to sanitize cookie values: public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException { r...

Why is this code throwing a ClassCastException and how to avoid it

Consider this code: import java.util.*; class jm45 implements Comparator<jm45> { private int x; jm45(int input) { x = input; } public static void main( String args[] ) { List list = new ArrayList(); list.add(new jm45(2)); list.add(new jm45(2)); Collections.sort(list); //faulty line } public i...

java - JNI/JNA - Get Window Title

Looking to get back into the development space; primarily using Java to call some native win32 functions (I don't desire to build in .NET).... Can someone point me to a place where I can read the title from a differnt running window using Java (JNI/JNA/SWIG). Assume you would know where in the memory space the application you are attemp...

Hacking RadioInfo.java to work

I have been looking at the android source and developing some apps. However for my next app, I need information about the cell phone. Similar to what you see when you go into "Field Test" mode. However I have not been successful to get RadioInfo.java to work. Is there a way to hack RadioInfo.java so that I can use it in my app OR is ther...

Inconsistent behavior on java's for-each

Consider this code: class Jm44 { public static void main(String args[]){ int []arr = {1,2,3,4}; for ( int i : arr ) { arr[i] = 0; } for ( int i : arr ) { System.out.println(i); } } } It prints: 0 0 3 0 What's this? For-each is supposed to run over all the el...

Looking for a good programmable Java CMS (Content Management System)

What would be a good choice of a programmable/extensible open-source content management system for Java developers? We've tried our hand at "Liferay" with a poor result after 15 months of work mostly due to its lack of programmability. It's not a product directed towards developers. We need to reboot the project now and we're looking f...

Widening equality check for Method type

Suppose I have an interface: public interface FooInterface { public void someMethod(); } and I have a class that implements this interface: public class FooClass implements FooInterface { public void someMethod() { //do cool things } public void someOtherMethod() { //do other cool things } ...

How do I return a pointer to a user-defined class object using SWIG

I have the following code wrapped by swig: int cluster::myController(controller*& _controller) { _controller = my_controller; return 0; } controller has a private constructor. What's the correct incantation to make something like this not throw an exception? public static void main(String argv[]) { controller c = null; ...

mvn tomcat:run doesn't start Tomcat

Hi all, I am trying to deploy and run my webapplication using maven and its tomcat plugin. I have set it up in project's pom.xml, but when I'm calling it from command line: mvn tomcat:run all that I get is: [root@ovz6022 trunk]# mvn -e tomcat:run + Error stacktraces are turned on. [INFO] Scanning for projects... [INFO] ------------...

Protecting against X11 Crashes in Java Applications that have a Swing Component

Is this possible? ...

jsp:setProperty equivalent for servlet

Is there an equivalent to: <jsp:setProperty name="beanName" property="*"/> for servlets? Something that will auto-populate the bean from inside a servlet using the request parameters? I'm refactoring a JSP-only application and would like to move some of the code to servlets. For a bunch of tragic reasons, we are not able (right n...

Counting trailing zeros of numbers resulted from factorial

I'm trying to count trailing zeros of numbers that are resulted from factorials (meaning that the numbers get quite large). Following code takes a number, compute the factorial of the number, and count the trailing zeros. However, when the number is about as large as 25!, numZeros don't work. public static void main(String[] args) { ...

How to stop a process with time constraints

I think the topic might not be accurate enough, but I really don't know how to describe it in a very brief way... What I want to do is as follows: I have a process running some analysis (in Java) and trying to give a return value, but the whole analysis has a time constraint, say 10 seconds If the analysis gives a result within 10s, ...