java

this = this in decompiled Java

I tried decompiling a Java application to which I do not have the source code and a strange thing showed up. At the top of the constructor for a class, there is a line that says this = this What does this (not this) mean? Is this just an artifact of the decompilation process? Or is it just some ugly hack? Can this be assigned to s...

Main loop in Android

I'm pretty new to java in general, but I have a bit of experience in C and C++. Normally in a C or C++ program there's a main loop/function, usually int main (). Is there a similar function that I can use in android java development? ...

in-memory DBs evaluation

Hi guys, I am trying to increase the overall Integration test execution time and I am currently evaluating various in-memory db solutions. The idea is to have DAOs hit in-mem db during the tests as opposed to hitting a real DB. This is a java app using Hibernate for persistence. I'd be interested to see your experience with one of thes...

Bytes in Java?

Thanks for all above answers but didn't really help me well just to give an idea what exactlty i wants to do: I am coding for some sort of packet which has different fields with differnt length in bytes so field1 is 2 byte long field2 is 3 bytes long field3 is 6 bytes long and when i addup these fields, i should be getting 11 bytes in l...

How to split a path platform independent?

I'm using the following code to get an array with all sub directories from a given path. String[] subDirs = path.split(File.separator); I need the array to check if certain folders are at the right place in this path. This looked like a good solution until findBugs complains that File.separator is used as a regular expression. It see...

Write Multiple Full HTML 'Files' to Single Output Stream?

I'm writing a testing utility- I want to show multiple finished HTML "pages" in a single browser window. Is this possible? I'm using Java Servlets. For example, normally the user goes to a utility screen, fills in a bunch of fields and POSTS this to my servlet, which builds up a full HTML stream based on their input and writes it to Ht...

Breaking on your own exceptions in IntelliJ

See this question on how to break on any exceptions. I'm getting a million exceptions on startup. I've tried ignoring ClassNotFoundException, but it's no good, the IDE still seems to break on these (and other) exceptions. So .. what's a decent configuration for this to catch only real exceptions caught from user code? (Ignore also any ...

Why is JFrame layout not the one I set?

If I set a layout on a JFrame with setLayout and then retrieve it with getLayout then I get a different LayoutManager. What is going on here?? public class Lay { public static void main(String[] args) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { java.awt.Container contain...

question about java constructor call syntax

Dear all. Unfortunately I haven't coded Java for about five years and I absolutely can not remember how or why the following code is working. I stumbled across a similar example and broke it down to this. The emphasis is on the part below the comment: I don't get the constructor notation followed by the block in double brackets. And ...

Major differences between J2EE and C#/.Net when developing Web Services

Having been primarily a .NET guy up until starting a new job recently; I've only done Web-Service development and consumption in C#/.Net. However I'm embarking on the journey to learn the ins and outs of doing it on the J2EE platform, and I'm curious what the major differences are in this specific type of development. Note: I have famil...

Find physical machine name in Java

How can I obtain the physical machine name that my jvm is running in? (Physical = OS, up to vmware...) ...

Deploying a Spring-based WAR with its JAR dependencies externalized.

I have a Spring app that has a lot of dependencies (18 megabytes of JAR files..) - Now, when I am testing on the remote Tomcat 6.0 server, I'd like to not have to upload that 19 megabytes of dependencies, and just upload the classes. Pretty simple, right? I can't get the damn thing to work. I'm using Eclipse 3.4, and if in Java Build ...

Java, console.readPassword adds extra line. How to delete it?

Hello! When i use console.readPassword() to read user passwords through console, there is always one line added to the console. How to disable this behavior or how to delete that extra line (and move the cursor after the last character in the line before)? What escape character to use? Thanks ...

what does this java error mean?

I'm trying to convince Zucker Reports to display a Jasper report but am getting a Java error and I don't speak java-ese. I see that there is a file not found error, but I can't figure out which file is not found. I replaced the long classpath with <SNIP>. error compiling report report2.jrxml - cmdline: javaw -classpath "<SNIP>" at....

Minimum version of Java required to run my applet

Hi, How can you determine the minimum version of Java required on a client's browser to run an applet that I've developed? I would like to do this so that I can determine, through, javascript, if the browser the user is running is capable of running my applet and displaying a message if not. Thanks in advance, Tim ...

Does java allow you to grab a segment of an array?

Hi all, I'm looking for a method that will return a section or segment of an array - like if I wanted only the 4th and 5th bytes of a byte array. I don't want to have to create a new byte array in the heap memory just to do that. Right now I have the following code: doSomethingWithTwoBytes(byte[] twoByteArray); void someMethod(byte[...

How can I find the error when Tomcat fails to start my Spring/Hibernate web application?

I have a Spring/Hibernate application which I have converted into a web application in order to provide RESTful web services (using Jersey). I am trying to deploy the web application onto Tomcat 6.0.20 and I get only a cryptic error message in the log file: Jul 8, 2009 2:25:22 PM org.apache.catalina.core.StandardContext start SEVERE: E...

Gantt Chart - JavaScript / JSP / Java / Groovy / Grails

I'm looking to add the ability to create a gantt chart to my web application. Currently my application is Grails based running on Tomcat. Research around SO seems to indicate that JFreeChart (http://www.jfree.org/jfreechart/) and Google Charts both might provide me with the ability to create charts that I could mold into what I need. B...

Storing uploaded images on Google App Engine with Java

I am looking at writing a Java web application on Google App Engine. I want to be able to upload and serve images from the app but just realised that the Datastore have a 1MB limit. This is slightly too little for decent pictures. Is there an alternative way you can suggest of doing this? Perhaps storing those as static content rather th...

With Eclipselink/JPA, can I have a Foreign Composite Key that shares a field with a Primary Composite Key?

My database has two entities; Company and Person. A Company can have many People, but a Person must have only one Company. The table structure looks as follows. COMPANY ---------- owner PK comp_id PK c_name PERSON ---------------- owner PK, FK1 personid PK comp_id FK1 p_fname p_sname It has occurred to me that I could remove PER...