I have a project which has shared functionality between three other projects and have linked these to existing projects as I normally would using the add project functionality of the libraries folder.
This all used to work however when I started up Netbeans yesterday it just wasn't working as in the other projects won't compile even though the…
Is it possible to get the class type from inside the static initialization block?
This is a simplified version of what I currently have::
class Person extends SuperClass {
String firstName;
static{
// This function is on the "SuperClass":
// I'd for this function to be able to get "Person.class" without me
// having…
Hello,
I wrote the question as a comment in the code, I think its easier to understand this way.
public class Xpto{
protected AbstractClass x;
public void foo(){
// AbstractClass y = new ????? Car or Person ?????
/* here I need a new object of this.x's type (which could be Car or Person)
I know that with…
How can you instantiate a Bimap of Google-collections?
I know the thread.
A sample of my code
import com.google.common.collect.BiMap;
public class UserSettings {
private Map<String, Integer> wordToWordID;
UserSettings() {
this.wordToWordID = new BiMap<String. Integer>();
I get cannot instantiate the type…
The problem is that I need to create in runtime a class like this:
public class Foo {
@Bar int value0;
@Bar int value1;
@Bar int value2;
....
}
with number of fields being decided at runtime.
I was looking at Javassist, and there you can create a new class, and add fields to it, but I haven't found a way to annotate…
I'm using the .startsWith() filter in a JDOQL query but it's case sensitive.
So startsWith("ab") doesn't return "Abc" result and so on.
Will I need to use a SQL query to avoid this ?
I have a data structure that is pretty simple (basically a structure containing some arrays and single values), but I need to record the history of the data structure so that I can efficiently get the contents of the data structure at any point in time.
Is there a relatively straightforward way to do this?
The best way I…
I have an class defining an immutable value type that I now need to serialize. The immutability comes from the final fields which are set in the constructor. I've tried serializing, and it works (surprisingly?) - but I've no idea how.
Here's an example of the class
public class MyValueType implements Serializable
{
…
Hi,
I came across PECS (short for Producer extends and Consumer super) while reading on Generics.
Can someone explain me how to use PECS to resolve confusion between extends and super?
Thanks in advance !
Hello all.
Problem:
I have to design an algorithm, which does the following for me:
Say that I have a line (e.g.)
alert tcp 192.168.1.1 (caret is currently here)
The algorithm should process this line, and return a value of 4.
I coded something for it, I know it's sloppy, but it works, partly.
private int counter…
Every single time I've read about the meta tags, the attribute where in this order for the description:
<meta name="description" content="..." />
First name, then content. It's also like that in the Google Webmaster documentation. Basically, it's like that everywhere.
Now in a .jsp (in XML notation) I've got…
I seek a solution to the age-old problem of managing string resources. My current implementation seems to work well, but it depends on using singletons, and I know how often singletons can be maligned.
The resource manager class has a singleton instance that handles lookups in the ResourceBundle, and you use it like so:…
I am trying to download a file from Sharepoint 2007 sp2 document library using GetItem method of the Copy webservice. I am facing the following issues :
In the local instance ( Windows Vista ) I can save only 10.5 Kb of any file. The webservice is returning only 10.5 Kb of data for any file.
On the production server,…
Hello,
I was wondering which libraries or API's would be useful in this. what im aiming for is to be able to type a command into a prompt and then specify which computer(out of all of them that are networked together) to execute that command on. the second part is i want to be able to see that command execute and the…
Hi,
I'm using Apache XML-RPC 3.1.2 to talk to an online-service. They have something special, they need a hash over the whole XML with a secret key for some kind of security, like this:
String hash = md5(xmlRequest + secretKey);
String requestURL = "http://foo.bar/?authHash=" + hash;
So I need the XML-request like…
I need a way to bind UI indicators to rapidly-changing values.
I have a class NumberCruncher which does a bunch of heavy processing in a critical non-UI thread, thousands of iterations of a loop per second, and some number of those result in changes to a set of parameters I care about. (think of them as a key-value…
GUI
i am trying to use JSpinner but as you can see from the attached image that it looks bad.
i am on windows 7. i was wondering if anyone knows how to make it look good?
just for clarity. bad means the edges dont line up and good means the spin control edges line up correctly.
thank you.
EDIT: maybe there is…
Hi I have the following date as String format.
Input
2010-04-20 05:34:58.0
Output I want the string like
20, Apr 2010
Can someone tell me how to do it ?
Dear All,
I am being driven mad the following (apparently hard) error from eclipse.
Publish failed using Ant publisher
Resource is out of sync with the file system: '/MyServlet/build/classes/com/inver/hotzones/database/BaseNetworkData.class'.
I have seen comments on similar errors where refreshing eclipses…
Hey everyone, I would like to wrap the String.format() method with in my own Logger class. I can't figure a way how to pass arguments from my method to String.format().
public class Logger
{
public static void format(String format, Object... args)
{
print(String.format(format, args)); // <--…
I am using Ganymed ssh to connect to a remote machine and apart from sending commands I need to send the arrows keys (left and right keys). I can send commands but when I send the arrows keys nothing happends.
This is what I have:
public boolean createShell() throws Exception
{
try
{
// ... …
I have to do a http post request to a web-service for authenticating the user with username and password. The Web-service guy gave me following information to construct HTTP Post request.
POST /login/dologin HTTP/1.1
Host: webservice.companyname.com
Content-Type: application/x-www-form-urlencoded…
Hi,
I am trying to do a conversion of a String to integer for which I get a NumberFormatException. The reason is pretty obvious. But I need a workaround here. Following is the sample code.
public class NumberFormatTest {
public static void main(String[] args) {
String num = "9.18E+09";
try{…