java

create mysql database from java

Is there any possability to create a database within mysql from java. I'm only aware of the String url="jdbc:mysql://localhost:3306/test"; Connection con = DriverManager.getConnection( url, "cb0", "xxx" ); syntax but here you have to specify a database name in the 'url'. But how do I create a mysql database when I only have a logi...

java.lang.OutOfMemoryError: Java heap space with NetBeans

This is the error I get when I run my web application using NetBeans (using servlets). To fix this I even changed the heap size in netbeans.conf, but still it shows the same error. How can I keep this from happening? HTTP Status 500 - -------------------------------------------------------------------------------- type Exception rep...

Writing a cleaner and more modular command-parser

I'm writing a debugger for a Z80-emulator we are writing in a school project, using Java. The debugger reads a command from the user, executes it, reads another command, etc. Commands can either be argument less, have optional arguments, or take an unlimited amount of arguments. Arguments are mostly integers, but occasionally they're s...

How to handle multiplication of numbers close to 1

I have a bunch of floating point numbers (Java doubles), most of which are very close to 1, and I need to multiply them together as part of a larger calculation. I need to do this a lot. The problem is that while Java doubles have no problem with a number like: 0.0000000000000000000000000000000001 (1.0E-34) they can't represent some...

What methods and interfaces do you (almost) always implement in classes?

Which methods and interfaces do you always implement in your classes? Do you always override equals()? If you do, do you also do hashcode()? toString()? Do you make it a habit to implement the Comparable interface? I've just written some code where I needed to implement compareTo() and override equals() to get my program to work in a s...

Getting the Invocation Name Used in Java

Hi SO, I'm trying to find a generic way to replicate this C functionality: int main(int argc, char** argv){ fprintf(2,"%s: error you did something wrong.\n", argv[0]); return 1; } in java. So far the only way was to hardcode this into the app, which is ugly. I'd like to get something similar to: someObj.getClass().getSimpleN...

In Java, how can I get user input in a console in a curses-like manner?

I just started learning Java at school for cse142, but I've known a bit of programming so am considerably ahead of the class and have been trying my own little projects. Normally if I run into a problem I just work around it because I figure I just haven't learned that yet, but this one bugs me enough to make a whole thread about it. I ...

After 17 years is it too late to fix C++ runtime extensibility?

The 1992 to 1993 timeframe was pivotal and fateful for C++. In the '92/'93 time frame I worked on a plugin architecture for Aldus PageMaker, which was coded in C++. PageMaker was built on a C++ OOP framework called VAMP, which assisted its portability between Mac OS and Windows. So we tried to use the features of C++ to build a plugin ...

Is Java 2 sufficient for getting SCJP Standard edition 6?

I am preparing for SCJP CX-310-065. But I am referring only to Java 2... Is it sufficient?? Or do I have to learn Java 6 for SCJP-065. Because Java 2 exam was already expired. Please guide me. ...

VM options in project properties in netbeans

I got a problem with the java heap space while using servlets in netbeans5.0 and got a solution to resolve it too,they asked to change the VM options of run category in the project properties.But,i couldnt find such option in my properties.Please do tell me what to do with this error. This is the picture of my project properties. ...

Scaling images/icons in Java

A project I am working on needs to be resized when the monitor resolution changes. Due to legacy code and other issues, we do it by using a custom library which scales all the components to the appropriate sizes when the resolution changes. However, when we scale some of the images/icons used in the project, they become blurry/fuzzy/ali...

Besides dynamic typing, what makes Ruby "more flexible" than Java?

I've been using Java almost since it first came out but have over the last five years gotten burnt out with how complex it's become to get even the simplest things done. I'm starting to learn Ruby at the recommendation of my psychiatrist, uh, I mean my coworkers (younger, cooler coworkers - they use Macs!). Anyway, one of the things they...

How to convert an ArrayList containing Integers to primitive int array?

I'm trying to convert an ArrayList containing Integer objects to primitive int[] with the following piece of code, but it is throwing compile time error. Is it possible to convert in Java? List<Integer> x = new ArrayList<Integer>(); int[] n = (int[])x.toArray(int[x.size()]); ...

Date arithmetic in Java

My program is about generating (producing) a Kurosawa and making the customers produce it. Every time we generate a Kurosawa, we have to print its id, its production date and expiration date, which is 3 months from the production date. My problem is: How can I calculate the date after 3 months? Thank you. ...

generate all 3*3 two dimentional arrays

how would i write a function in java that generates all the 3*3 multidimensional arrays such that every number between 1...9 only appears once? thanks! ...

Java Panel

Is it possible to add more than 500 components to a panel at runtime in Java?? ...

Java composition question

A question about composition and object orientation: I am trying to implement more features for a class (Java TreeMap as an example). public class TreeMap<K,V> extends AbstractMap<K,V> implements NavigableMap<K,V>, Cloneable, Serializable Using composition is the way to go on this, so I would have to create first a reusable ...

How to display japanese characters in JTextArea

There is strange behaviour of JTextArea when displaying japanese characters - I get well-known blank rectangles instead of kanji. The mostly strange thing is that JTextField displays them perfectly (in both cases I use "Tahoma" font family). Also, if I put this code: Font f = new Font("123", Font.PLAIN, 12); // This font doesn't ex...

jsp get ip address

Hello, whats the best way of preventing someone from voting twice? How do i get the users ip address? What if they are on a large network? will everyone on that network show the same ip? thanks UPDATE: request.getRemoteAddr() and request.getRemoteHost() return the Server names, not the client's host name and ip. Anyone else got any br...

Java Swing: How can you alter the margins in Nimbus Look and Feel

I'm trying to use Nimbus Look and Feel and I can't simply plug it in to replace other Look and feel because it adds some external padding around each component. So, I would like to remove this padding. This is the list of defaults that can be changed, however the following code changes nothing. UIManager.put("Button.contentMargins", ne...