java

Java applet with init() in a package?

Hi. I'm wondering if you can put the main class (or the class with the init method, whatever) inside a package and still have it run in a browser? Most of the time I put my applets into the (default package) but my applet here is in a package, so can I still embed it into the webpage? I've googled it with little results. Say I've got M...

Window events for JFrames that are hidden/shown via setVisible?

Which sort of listener do I have to add to a JFrame to detect when it is being hidden/shown via setVisible? I tried using a WindowListener and the windowOpened and windowClosed methods, but they only work for the first time that a window is opened (windowOpened) or, respectively, when the window is closed using the dispose method (windo...

performance of REST architecture for java / csharp messaging

i currently have an application that sends XML over TCP sockets from windows client to windows server. we are rewriting the architecture and our servers are going to be in Java. one architecture we are looking at is a REST architecture over http. so csharp winform clients will send info using this. We are looking for high throughput ...

How to build a Tiled map in Java for a 2D game??

Not sure how to approach this problem. Basically, I want a Pixel -> Tile representation of a 400x400 window. Each coordinate on the screen, e.g 120x300 should be part of a tile. My smallest sprite is 4 pixels, so we can say that 1 tile = 4 pixels. The player and enemy sprites are all 20 x 20, so each player/bad guy will occupy 5 tiles. ...

Java object reference/scope question

If I have a member variable such as this (declared in the body of a class) private Dot[] dots=new Dot[numDots]; I loop through all members of this array, and: 1) Pass every Dot object to a function of another class, which: 2) Passes it to yet another function of a 3rd class, if some conditions are met 3) And the 3rd class changes s...

Help with an Exception

Encounter the following exception. Anyone have any idea how to resolve this? Or what is the issue exactly. [#|2009-03-03T10:41:18.079+0800|SEVERE|sun-appserver-pe8.2|ilog.rules.teamserver.model.IlrGlobalCache|_ThreadID=12;|java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.RemoteE...

Java castor using custom field handlers

Hey, I have been trying to write a custom field handler which returns the hash code of a java.awt.Image object when writing to XML and retrieves an image based on this hash code when binding the XML to an object. For some reason, I can't get this to work; castor, from what I can tell, simply instantiates the field handler and then does...

Java Drag and Drop to native os

I've been looking around for some time and have yet to be able to find any libraries or information for Java on how to drag lets say an ImageIcon onto a Windows folder and get the path as to where you "dropped" the ImageIcon. I'd really like a platform independent solution that works across OSX/linux/Win, but at the very least would like...

Path finding in a Java 2d Game?

Essentially its a pacman clone game I'm working on. I have an Enemy class, and 4 instances of this class created which all represent 4 ghosts of the game. All ghosts start up in random areas of the screen and then they have to work their way towards the pacman character. As the player controls the pacman, moving it around, they should f...

How to deploy an applet?

I've built a small applet and I have all the .java class files. How can I now compile/build it so I can use it in an <applet> tag? An eclipse based method would be best. Also, I'm using some images in the applet. 1) Do I need to upload these images to my website 2) Right now I point to them using my local path e.g C:\java\project\imag...

Android (Java) network programming resources

Hi, I would like to develop an application for Android which would transfer data through TCP connection. Does anyone know for any good example or book where client-server connection example could be found? I'm quite new with Java and Android so I would be very thankful for any suggestion. ...

Dynamic SQL Java library

We need to generate dynamic SQL in our Java app. Does anyone know a simple library to do this? In our Java app we have a bunch of where clause filter criteria (database column, operand, value). In other words, we could have a Date instance that we need to use to filter a given datetime Oracle column, a String instance that we need to...

What is the definition of "accessor method"?

I've been having an argument about the usage of the word "accessor" (the context is Java programming). I tend to think of accessors as implicitly being "property accessors" -- that is, the term implies that it's more or less there to provide direct access to the object's internal state. The other party insists that any method that touche...

Handcode GUI or use gui-designer tool

I would like to hear some opinions on hand coding your GUIs as one typically do when using Java or Qt with C++, vs using a gui-designer tool? Examples of GUI designer tools would be MFC GUI-designer, Qt designer, Interface Builder (Apple). I used to be a fan of hand coding but from recent experience I have switched. The problem I have s...

"cannot find symbol variable BufferUtils"

I'm trying to load an image into Java to create a texture in JoGL. I need to use a call to BufferUtils for this: dest = ByteBuffer.allocateDirect(data.length * BufferUtils.SIZEOF_INT); But it's telling me that it can't find it. This is all I have imported: import javax.media.opengl.*; import javax.media.opengl.glu.*; import com.sun...

Why doesn't Java have a way of specifying unescaped String literals?

In C#, if you want a String to be taken literally, i.e. ignore escape characters, you can use: string myString = @"sadasd/asdaljsdl"; However there is no equivalent in Java. Is there any reason Java has not included something similar? Edit: After reviewing some answers and thinking about it, what I'm really asking is: Is there any ...

How do you unescape URLs in Java?

When I read the xml through a URL's InputStream, and then cut out everything except the url, I get "http://cliveg.bu.edu/people/sganguly/player/%20Rang%20De%20Basanti%20-%20Tu%20Bin%20Bataye.mp3". As you can see, there are a lot of "%20"s. I want the url to be unescaped. Is there any way to do this in Java, without using a third-part...

What career path should I take?

I have a decent experience with C++. I am a new linux user...just started with shellscripting. Besides this I am thinking of studing java (due to its platform independence). I am too confused about what to do, as the demand is changing too rapidly. I would like some help with what I should study. I am not interested in application deve...

Where do I find a standard Trie based map implementation in Java?

I have a Java program that stores a lot of mappings from Strings to various objects. Right now, my options are either to rely on hashing (via HashMap) or on binary searches (via TreeMap). I am wondering if there is an efficient and standard trie-based map implementation in a popular and quality collections library? I've written my own...

Why won't my texture show up?

Okay, I'm using Java and JoGL. I'm trying to load and display a texture, but the texture isn't showing up at all. I'm not getting any errors at all, so I don't know what the problem could be. import javax.media.opengl.*; import javax.media.opengl.glu.*; import com.sun.opengl.util.*; import com.sun.opengl.util.j2d.*; import java.awt.*; ...