What's the difference between doing this:
public class SomeClass {
SomeObject obj = new SomeObject();
//rest of the code
}
and this
public class SomeClass {
SomeObject obj;
public SomeClass(){
obj = new SomeObject();
}
//rest of the code
}
...
I am currently reading about SWT. There is often written, that Eclipse as an SWT application looks like the standard GUIs of the host platform or OS. But I dont think so. At least under windows the tabs of the eclipse views does not look like the standard windows tabs.
Why is this?
Was this ever different?
What about other SWT applicat...
So I have a directory of with a bunch of sub-directories that contain .java and .form files. How do I build this program? I'm sure that the program is build-able too, so I must be doing something wrong.
I'm used to writing C/C++ programs where I can just pass -I/path to gcc.
By the way, I'm using netbeans on an Ubuntu system.
Her...
In a project that I'm current working on, I'm using Eclipse with the Jigloo Gui Builder.
The builder creates the class with this class line:
public class ChatServer extends javax.swing.JFrame {
String fromclient;
String ToClient;
String serverName = InetAddress.getLocalHost().getHostAddress();
String clientName = "";
...
/*This is a program that calculates Internet advertising rates based on what features/options you choose.
*
*
*/
import java.util.Scanner;
public class InternetAdvertising
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int numberOfWords;
//I assigned 0 values to both as...
How to resolve these following errors... Am I missing some jar file???
log4j:WARN No appenders could be found for logger (smslib).
log4j:WARN Please initialize the log4j system properly.
org.smslib.GatewayException: Comm library exception: java.lang.RuntimeException: javax.comm.PortInUseException: Port currently owned by Unkn...
is database connectivity possible in applet???
...
Recently I've been craving some game programming. I primarily use Linux, and was wondering if there are any good graphics libraries for Java development on Linux? Google didn't turn up very much useful information on the subject.
Also, would another language be better? I would like to avoid using python -- Ruby and Java are my two favor...
This question might have asked here number of times . After doing some google search for the above error and doing some update, I can't understand why I'm still getting that error. I've already put my driver-- mysql-connector-java-5.1.5-bin in the classpath:
Java_Home\jre\lib\
Java_Home\jre\lib\ext\
Java_Home\lib
and the code which I'...
I have a java chat applet that's compatible with JDK1.1 so it works well even with Microsoft JVM.
the thing is, sometimes the chat area within the applet becomes white and messed up.
It can only be fixed back by closing the whole Internet Explorer (all windows and tabs) and restarting it.
this doesn't exist when running the applet on ...
Suppose we are developing class which implements simple CRUD operations for working with DB. This class also maintain cache for increasing performance.
public class FooTableGateway {
Map<Integer, Foo> id2foo = new HashMap<Integer, Foo> ();
public void getFoo (int id) {
if (id2foo.containsKey (id) {
return id2foo.g...
Since switching to JRE 6, my server's code cache usage (non-heap) keeps growing indefinitely. My application creates a lot of classes at runtime, BUT these classes are successfully unloaded during the GC process. I can see these classes getting unloaded in the gc logs and also the permGen usage stays constant. I specifically make sure in...
I use the following code:
Calendar calendar = new GregorianCalendar(0,0,0);
calendar.set(Calendar.YEAR, 1942);
calendar.set(Calendar.MONTH, 3);
calendar.set(Calendar.DAY_OF_MONTH, 4);
Date date1 = calendar.getTime();
calendar.add(Calendar.DAY_OF_MONTH, -1);
Date date2 = calendar.getTime();
System.out.println(date1 + "\n" + date2);
...
When i try to initialize velocity engine using
VelocityEngine engine = new VelocityEngine();
engine.init();
I encounter the same error when i try
Velocity.init();
org.apache.velocity.exception.VelocityException: Failed to initialize an instance of org.apache.velocity.runtime.log.ServletLogChute with the current runtime configura...
Is there a way to write a Java Swing application with a custom chrome? Please take a look* at the frame for Microsoft's Zune 4.0 software.
I realize that colors, the shape of scroll bars, etc. are controlled by skins or looks and feels. Right now I'm trying to tackle the native window which houses the java components--the title bar ma...
I built a client server application using an IDL file for client server communication across the network. Both the client and server programs are in java. When the user enters exit, both the server and the client exit. However I'm unable to kill the nameserver process.
I started the nameserver using the command
tnameserv -ORBInitialPo...
How Does the toString(), ==, equals() object methods work differently or similarly on reference and primitive types?
...
I'm currently working on my first GUI Programming project in Java as a school assignment. I've gotten pretty familiar with setting up classes and methods in Java, though with the introduction to GUI programming, I'm not sure how best to go about it.
I've set up the GUI in its own package. Should I make a new class for each JPanel? I've...
I'm getting a "java.lang.string cannot be cast to node" exception. I thought of converting the localRoot to a string using a provided toString method then comparing them, nut this leaves no concept of 'greater than' or 'less than' which I need to navigate the BST...
int computeResult = ((Node<E>)o).compareTo(localRoot);
where
o is o...
I am contemplating writing a program that will move some newly created dirs to another that puts them into date-stamped folders; either by week-month-year or month-year. I can probably write/debug/test this in java in 1.5 hours, BUT
I would like to know if anyone else has had to deal with this, and perhaps has done it with a windows bat...