java

How do you make websites with Java?

This might be a really trivial question, but I've been writing Java programs at my school. But I just found out that I can create websites with Java as well. How can I do that? Any good books/tutorials for that? Also, I know about PHP, which is better for Web development? Also, when using PHP, MySQL comes into picture and while writing J...

I've downloaded Apache POI, but when I try to use it my code doesn't compile

I've recently download poi-src-3.2-FINAL from apache.org. Now I can't write these: import org.apache.poi.poifs.filesystem.*; import org.apache.poi.hwpf.*; import org.apache.poi.hwpf.extractor.*; Now I can't use the classes of HWPFDocument and WordExtractor. I can only import org.apache.*; Did I forget to download any other thing?...

How would you read image data in from a program like Image Magick In Java?

I am working with ImageMagick and am wondering what the best way to read image data in from StdOut of the ImageMagick process. I an invoking the command to the process like so: /opt/local/bin/convert -resize 8000@ - - and then piping a byte array to the process for processing. what is the best way to read data from a process like th...

repeated logging in log 4j in java

I used log4j in a java program. I initialized it with : BasicConfigurator.configure(); // logger configuration try { logger.setLevel(Level.DEBUG); } catch (Exception e) { System.out.println("Logfile not found"); } But, during the execution of the program i get 3 log statements instead of one. For example, 3 lines 1047 [mai...

Java Swing packs the window wrong

I'm making a Scorched Earth like game in Java (for my exam project :D), but I have this problem. I'm drawing a window (JFrame), setting layout to BorderLayout, applying an extended JPanel, and packing the window, but after it has been packed, it's showing some extended white space at the left and bottom border. This is my main class: p...

How to read sprites from a spritesheet in Java?

I have this sprite sheet: How can I read the sprite that I want to out of these? ...

Natural language parsing, practical example

I am looking to use a natural language parsing library for a simple chat bot. I can get the Parts of Speech tags, but I always wonder. What do you do with the POS. If I know the parts of the speech, what then? I guess it would help with the responses. But what data structures and architecture could I use. ...

Java: Using Castor XML with images

Hey, how can I use Castor XML to marshal a java.awt.Image object to XML, or make the XML reference the image in some way. Cheers, Pete ...

Swing JList binding questions

I have a JList which i want to use to display a list a caches that are added in from another form, I've got this working and I want to be able to add the caches directly to the list... Is there a way to change what gets displayed to the user? or would it simply be a case of making to the toString method of my object what i want to be dis...

What does your Java development environment consist of?

I am looking to start fiddling around with Java development in my free time (professionally a .NET developer) and I am curious as to what the community feels is their preferred development environment. Items that could be listed: IDE Plugins Tools Utilities Source/Version Control Libraries Books Blogs Anything ...

area of intersection between circle and rectangle

i'm looking for a fast way to determine the area of intersection between a rectangle and a circle (I need to do millions of these calculations) A specific property is that in all cases the circle and rectangle always have 2 points of intersection. Java lib would be awesome! Thanks, Britske ...

Is there anything like RhinoMocks in Java?

What would be the closest resemblance? ...

How can I use Java to take a "screenshot" of displayed HTML?

Do you know how to convert (save) HTML to an image? Any format is acceptable: jpg, png, ... I tried this code but it does not correctly convert images from HTML (<img> tag). A solution in Java would be preferred; however, I would appreciation any approach. ...

How to show Pacman's mouth open/close animation in Java with double buffering?

I'm trying to show the famous mouth opening/closing animation of the pacman character in a throwaway pacman game I'm making to teach myself game programming. What I'm doing is drawing the open mouth image, then redrawing the closed mouth image at the exact same (x/y) location. But this doesn't work, and I just see the closed mouth anima...

Pacman maze in Java

So I'm building the pacman game in Java to teach myself game programming. I have the basic game window with the pacman sprite and the ghost sprites drawn, the pacman moves with the arrow keys, doesn't move beyond the walls of the window, etc. Now I'm trying to build the maze, as in this picture: Without giving me the direct/complete ...

How do reflection and remoting work internally?

I am curious to know how Reflection and Remoting in .net work internally. I also hear that .net can use remoting to communicate with applications written in other languages (such as Java). How does that work? This is probably a large question so an answer that briefly touches upon each question is reasonable. ...

How to represent a 400x400 window as a map in a Java game?

I'm building a pacman game. Basically, I want to have a map representation of this window consisting of blocks/tiles. Then as the pacman character/ghost moves i would change their position on the map to represent what's on the screen, and use that for collision detection etc. How can I build this map, especially since the screen is made...

How to check if an element in array exists in Java

If I have an int array structured like this: private int[][] map = new int[400][400]; And I try to retrieve map[100][200] And that element isn't initialized, will i get a compiler/runtime error or will it return null? And is there any function to check if a given element/index exists/has been set? ...

What to use for password hashing? Any reason not to use jBCrypt?

I'm planning to use jBCrypt for password hashing in a new web application, as it is supposed to be the best from what I've read. As I haven't used it before I'm looking into if there is any reason not to use it. I have this: I haven't found it in the Maven repository (searched for jbcrypt and bcrypt at mvnrepository.org) which is a do...

Can I mock a super class method call?

Sometimes, you want to test a class method and you want to do an expectation on a call of a super class method. I did not found a way to do this expectation in java using easymock or jmock (and I think it is not possible). There is a (relative) clean solution, to create a delegate with the super class method logic and then set expectati...