I have the following code:
public class boolq {
public static void main(String[] args) {
boolean isTrue = true;
isTrue ? System.out.println("true"): System.out.println("false");
}
}
when I try to compile it i get this:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
...
How do I get the current date in Java?
In C# it is DateTime.Now.
...
I have learned that the best way to learn a language is by finding a good project to start on, and working out how you would create it. I've been programming for 4 years as a hobby, and it's only been in PHP, so I decided that I should learn a "real" programming language. I have tried C++ in the past, however I was never able to find a p...
Is there a shortcut in netbeans to highlight a block of code and comment/uncomment it?
...
Hi,
I am looking for a Java regexp lib with support for recursion, like:
"<a+(?0)>"
JDK does not support it, ORO does neither.
Anyone knows about such?
Thanks,
Ondra
Edit: See http://www.php.net/manual/en/regexp.reference.recursive.php
And I need it for this expression:
(?:mUi)^/--++ *+(.*)(?: *(?<= |^)\\.((?:\\([^)\\n]+\\)|\\[[...
how to debug/step through a simple java 'main' application using netbean?
I want to set breakpoints and analyze the value of variables etc.
...
i thinking of doing this architecture
genericdao +interface ---> servicelayer+interface---> view layer
my dao will only have generic methods, my service layers will have real logic for instance
service layer method
string executeThis= "select c from com.abc.test.User where username =:username";
Map tempMap = new HashMap();
tempMap...
i have a java program connect to server through xot protocol.
My lib i use can handle connect timeout, but there is no method like setSoTimeout() to handle timeout when send & recv data.
so, anyone could suggest me some solution for this problem.
thanks
Quan
...
I have a string that looks like:
http://www.example.com/index.do/blah/1_44/asdf/asdf/asdf
http://www.example.com/index.do/blah/1_44_2342/asdf/asdf/asdf
I need to grab the value 44 from the above, ofcourse '44' could be any number.
The number '44' always is prefixed with a _, and after it could be another _ or /.
I have no idea of the...
I am trying to match any or all from a set of phrases in a given string. Here is my regex:
(^|\\W)(" + phrase1 + "|" + phrase2 + "|" + phrase3 + ... ")(\\W|$)
I need to be able to match any number of the phrases I am ORing. It seems to work okay except when two phrases occur immediately next to each other. So "phrase1 lorem ipsum phra...
I want the entire HTML for a given HtmlPage object.
What property should I use?
...
The following code sample is an implementation of the Strategy pattern copied from Wikipedia. My full question follows it...
The Wiki's main method:
//StrategyExample test application
class StrategyExample {
public static void main(String[] args) {
Context context;
// Three contexts following different strategie...
I'm looking to record keystrokes and mouse positions while I'm in a browser window on various websites, but I'm not sure how to do this outside the SWING (or some other GUI) window.
How can I record keystrokes when a different application's window is the one active?
...
I'm having a weird problem with TreeSet (sortedNodes) and ArrayList (nodes). In my program, I have in a method called from Event Dispatch Thread (from ActionListener) these lines:
System.out.println("nodes: "+nodes.size());
sortedNodes.addAll(nodes);
System.out.println("sortedNodes: "+sortedNodes.size());
Probl...
How can I have each call to save commit to the database?
I don't want to, at each interation of a loop that I am in, to call commit and then restart the transaction.
for my application, just having a commit at each session.save is fine.
...
So I am using HtmlUnit, and the method's signature looks like:
public HtmlAnchor getAnchorByText(String text)
throws ElementNotFoundException
So this means, the call to this method won't just return null, but it will throw an exception.
(I find this a pain!!, in c# methods usually just return a null if not ...
I've been having a (ironic) play around with the Play Framework and have been impressed thus far. I was just curious as to what other Java frameworks are out there that have a similar feature to Play in that you are able to get immediate feedback when making changes to your code base without having to re-build or re-deploy your app?
...
I am using hibernate, and my classes property is a string, and my mapping doesn't have any type information, ie:
<property name="html" />
I am storing a web page in the html database column, and for some reason the entire page isn't saving, it gets cut off part way.
I outputed the value of the property to console and it does outpu...
How do you return a JSON object form a Java servlet.
Previously when doing AJAX with a servlet I have returned a string. Is there a JSON object type that needs to be used, or do you just return a String that looks like a JSON object e.g.
String objectToReturn = "{ key1 = value1, key2 = value2 }";
...
I want to make Restful - Web Service using netbean 6.5, glassfish V 2 , and i already make table and the relationship between table. But when i want to test restful Webservice, some table it show
HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling t...