java

Converting an array of Pixels to an image in C#

I have an array of int pixels in my C# program and I want to convert it into an image. The problem is I am converting Java source code for a program into equivalent C# code. In java the line reads which displays the array of int pixels into image: Image output = createImage(new MemoryImageSource(width, height, orig, 0, width)); can so...

Good language to develop a game server in?

Hello, I was just wondering what language would be a good choice for developing a game server to support a large (thousands) number of users? I dabbled in python, but realized that it would just be too much trouble since it doesn't spawn threads across cores (meaning an 8 core server=1 core server). I also didn't really like the languag...

How to show syntax errors in an eclipse editor plugin

How can I indicate syntax errors (e.g. an illegal sequence of tokens) in an eclipse editor plugin just like in the eclipse Java editor, i.e. by red wriggly underlines, a red marker on the scrollbar that you can jump to, and an explanatory message when you hover over either one? I'm writing an eclipse editor plugin for a custom file form...

Ragel - validate a String while Input

Assume we want to validate user input, while user is typing in a JTextField. For validating the user input, I wonder if I could use Ragel. Assume the input should follow this example regex: [a-z]{2,5}ABC[0-9]+ How can I do this with ragel? Can anybody give a short example how to validate user input "on the fly" (while inputing) with...

Do any other developers get yelled at for making every thing public?

I am sick and tired of getting yelled at when I make all my variables in a Java class public, for the sake of not needing to write five times more code for getters and setters. Do others share this problem? ...

maximal element in an array in Java (Collections.max() for integer arrays int[])

Is there anything like Collections.max which finds the maximal value in an array for regular arrays in the standard java runtime library? ...

Mocking HTTP Server

Hello, I would like to write tests for my client code, which accesses HTTP Server. I am looking for simple HTTP Server, which would simulate responses from real server. Such HTTP Server (mock server :-)) should verify all requests really came from my client code verify that requests had all required parameters send response, ideally...

Regular Expression to extract label-value pairs in Java

I have a file containing several lines similar to: Name: Peter Address: St. Serrano número 12, España Country: Spain And I need to extract the address using a regular expression, taking into account that it can contain dots, special characters (ñ, ç), áéíóú... The current code works, but it looks quite ugly:. Pattern p = Pattern.com...

Converting a generic argument to an int in java, provided that it is a number.

Here's what I've been trying to do, in a nutshell: class example <T extends Number> { private int function(T number) { int x = (int) number; ... } ... } Basically, I'm trying to make it so that T is a number so I can convert it to an int inside that function. The problem is that I'm getting an "incovert...

Java cast error trying to create a generic array of custom made class.

This is what I'm trying to do: import java.lang.reflect.*; class exampleOuter <T extends Number> { private exampleInner<T>[] elements; public exampleOuter(Class<T> type, int size) { elements = (exampleInner<T>[]) Array.newInstance(type, size); } } I was told that if I wanted to create generic arrays of type T...

Java - UserInput.* doesn't work on my Mac

I do most of programming work on the Windows terminals in my university. However, my computer is a Mac and, for some reason, the javac command throws up an error when I use UserInput methods. Is there anything to install or an alternative command to use to make this compile properly? ...

Any chumby programmers out there? What's a good resource for chumby beginners?

I just got this Chumby thing for Christmas. I was thinking of writing a StackOverflow widget for it. Does anyone know any caveats to programming this, or especially good things for chumby virgins to know? I have not yet begun to do my research. I guess it's just a Linux device which runs java widgets. ...

Java doesn't seem to be comparing Doubles right.

I created a Linked List, with insert, search and remove functions. I also created a iterator for it. Now, suppose I do this: myList<Integer> test = new myList(); test.insert(30); test.insert(20); test.insert(10); myList.iterator it = test.search(20); if(it.hasNext()) System.out.println(it.next()); And voila, it works (it prints th...

Would you recommend Java/Glassfish/Metro for brand-new project?

I developed in ASP.NET 2.0 for some time, and for slightly less time in Java/Spring/Hibernate. Right now I start developing new web-service and am confused with the choice of: .NET WCF 3.5 versus Java/Metro. From one side, WCF seems like a brilliantly developed solution, a masterpiece of software frameworks, with all the support for fu...

Good tools/frameworks to develop a game server in Java?

I am making a game server for a turn based game. Not a web based server, but a process-based one. I want it to be scalable and I want the development process to go as smoothly as possible. I haven't used Java in forever and I need to brush up on my skills, so I really have no idea what is out there framework or tool-wise. Right now it lo...

How to set a list of integers while preparing SQL queries in Java

I have a query like this - select * from tbl where ... and colname in (2,3,4) When I prepare the query (... ' colname in (?)' ) using a PreparedStatement in Java, what setter method should I call to set these integers ? The integers are available in an int array and the size varies. If it matters, the database is MySQL and the column i...

Difference between Atg and Struts

What is the difference between Atg and Struts? ...

How to prepopulate model objects with test data from file?

I have some model objects I'm using in my Java client application. Later these model objects will be populated / retrieved from remote services (e.g. SOAP). Now I want to do manual / automatic testing of the frontend before implementing these services. The model objects are mostly POJO and I want to store some sample test data in files a...

My very first project. Any suggestions on what to make?

I've repeatedly read that it's great for budding programmers to find a cool project he/she is interested in, so here I am. I'm a beginner-intermediate Java learner and I'm looking for a project to do. At first I was thinking about creating a simple game (inspired by www.java4k.com) but I found no tutorial that guides me at my level. ...

the Nice programming language as an alternative to Java generics

I've been reading Bruce Eckel's Thinking In Java and in the chapter on generics, he briefly mentions the Nice programming language as something that handles parametrized types better than Java, but compiles into Java bytecode. Does anyone have any experience with this? Generics make my head hurt, so the prospect of an alternative that i...