Sagewire Logo

java language RSS Feed

Recent Posts View Recent Posts | View Archived Posts

Message from javamix
Most recent post: 9/6/2007
2 authors and 2 replies.

Hi,

I have created a website which aggregates JAVA news. I created the
site as I was a frequent visitor to JAVArss which is no more.

I hope is is of use to you:

http://www.JAVAmix.co.uk/ read more about JAVA Mix


Message from Charter Newsgroups
Most recent post: 9/3/2007
2 authors and 3 replies.

I have a program where I'm finding the factorial of an int using both
recursive and non-recursive methods. Both methods work fine up through an
input of 12; however, when I try for 13 or more, they produce different
results. It does not seem as if it should do this. The program is below (you
can modify the upperLimit near the beginning); can anybody help me
understand why this is occurring?

import JAVAx.swing.*;

public class Factorial
{
public static void main(String[] args)
{
int numberToFindFactorialOf;
String userResponse;
int upperLimit = 12; // Found through trial and error

// Get integer from user
userResponse = JOptionPane.showInputDialog(null,
"Please enter a number from 1 - " + upperLimit +
" to find its factorial:");
numberToFindFactorialOf = Integer.parseInt(userResponse);

// Ensure proper response
while(numberToFindFactorialOf < 1 || numberToFindFactorialOf > upperLimit)
{
userResponse = JOptionPane.showInputDialog(null,
" > INVALID RESPONSE <<<\n\n" +
"The number must be within the range of 1 to "
+ upperLimit + ". Please enter a valid number:");
numberToFindFactorialOf = Integer.parseInt(userResponse);
}

// Call the two factorial functions, displaying result
JOptionPane.showMessageDialog(null, "The factorial of " +
numberToFindFactorialOf
+ " using recursion is " + factRecur(numberToFindFactorialOf) + ".");
JOptionPane.showMessageDialog(null, "The factorial of " +
numberToFindFactorialOf
+ " using i read more about Strange discrepancy


Message from rjboney
Most recent post: 8/28/2007
2 authors and 2 replies.

Vista to JAVA User Interface Problem

Rodney Boney (rjboney@xxxxxxxxxxx)I got an error msg [JAVA Not Found or Not Working]while trying to play
POGO.com games on 7/3/2007. Pogo had worked prior to today. Something has
changed, but I cannot figure it out. I can log on to Pogo ok and play
non-JAVA based games. When I select a JAVA based screen it goes to game
popup and starts loading then popup closes and site goes to error msg.
screen. It does this whether I use IE7.0 or Firefox 2.0, I get the same
error. JAVA console is enabled for Tray but doesn't show with browser in
use, therefore cannot check JAVA execution steps.

JAVA doesn't work for Vista User Login rjboney. Everything works ok if I
logout and login under Vista User Login pdboney. Both accounts have the same
administrator rights and security. I ran the following tests.

Vista User Acct. pdboney JAVA test results:

Ran JAVA.com JAVA test and it shows installation ok.
Ran Pogo's EA support test for JAVA with results:

JAVA 1.6.0_01 (Sun Microsystems Inc.)
Windows Vista 6.0 (x86)
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR
2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)

Vista User Acct. rjboney JAVA test results:

Ran JAVA.com JAVA test and it goes to web site:
http://JAVA.com/en/download/help/testvm.xml No test seems to run.
Ran Pogo's EA support test for JAVA with results:
No info just a square with a red [X].

I have checked and/or tried the followi read more about Vista to JAVA problem with only one User? Please Help!


Message from Lionel van den Berg
Most recent post: 8/22/2007
3 authors and 6 replies.

Is it possible for me to setup everything necessary to run a JAVA
application on my local machine WITHOUT using any servers? If so, how?

I have placed everything I need in a local directory but it complains that
it can not find the file:

JAVA.io.FileNotFoundException: /home/Documents/TCI
Works/FileViewer/web/index.jnlp (No such file or directory)

I'm using the following example to play with:

http://www.ibm.com/developerworks/opensource/library/os-jws/#resources

Thanks

Lionel. read more about Possible to use JWS on local file system?


Message from Crackles McFarly
Most recent post: 7/30/2007
5 authors and 5 replies.

Is their a website or even a book to get me started in learning how to
program in the more popular JAVA and C/C++ languages?

I'm not asking anyone to homework for me either, I am not in school.

Please help if you can.
thanks read more about Is their a website to get me started programming?


Message from Yogi_Bear_79
Most recent post: 7/27/2007
2 authors and 4 replies.

I am having a problem with my code below. It compiles, however whenever I
click the Countbutton I get a slew of output information in my command
window. It starts with: Exception in thread "AWT-EventQueue-0"
JAVA.lang.NullPointerException at
WordCunter.actionPerformed{WordCounter.JAVA:43)

I think I have the program pretty much correct, I am stuck on getting the
results (words counted) to appear in the JtextField after I press the
CountButton, Thanks for any help.

import JAVA.awt.*;
import JAVA.awt.event.*;
import JAVAx.swing.*;
import JAVA.util.*;

public class WordCounter extends JFrame implements ActionListener
{

public JTextArea textPane;
public JTextField fieldWordCount;

public WordCounter()
{
super("Tammy's Word Counter Demo");

Container c = getContentPane();

//button panel
JPanel buttonPanel = new JPanel();
JButton countButton = new JButton("Count Words");
buttonPanel.add(countButton);
countButton.addActionListener(this);
JLabel labelWordCount = new JLabel("Word Count = ");
fieldWordCount = new JTextField(5);
buttonPanel.add(labelWordCount);
buttonPanel.add(fieldWordCount);
c.add(buttonPanel, "South");

//text panel
JPanel textPanel = new JPanel();
c.add( textPanel, "Center");
JTextArea textPane = new JTextArea(12,32);
textPane.setLineWrap(true);
JScrollPane scrollPane = new JScrollPane(textPane);
textPanel.add(scrollPane);

}//end WordCounter constructor

public voi read more about Help with Button action


Message from Yogi_Bear_79
Most recent post: 7/26/2007
2 authors and 4 replies.

I am getting the error in the subject of this post whenever I attempt to run
this compiled program. I have tried various GUI & command line attempts to
run it, all with the same results. I have scoured the net, and I have not
found a clear anwser to my issue. If you do not mind please look this over
and let me know what I may be doing wrong. Thanks

import JAVA.awt.*;
import JAVA.awt.event.*;

public class Checkerboard extends Frame implements ActionListener
{

//Declaring variables
int start, stop, step;

Panel boardPanel = new Panel();
TextField panelDisplay[ ]= new TextField[16];

Panel buttonPanel =new Panel();
Button goButton= new Button ("Go");

Panel inputPanel = new Panel();
Label startLabel = new Label ("Start");
TextField startField = new TextField(2);
Label stopLabel = new Label ("Stop");
TextField stopField = new TextField (2);
Label stepLabel = new Label ("Step");
TextField stepField = new TextField (2);

public Checkerboard()
{
this.setLayout(new BorderLayout());
boardPanel.setLayout(new GridLayout(4,4));
inputPanel.setLayout(new GridLayout(2,3));
buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));

for (int i=0; i<16; i++)
{
panelDisplay[i]=new TextField(i);
panelDisplay[i].setEditable(true);
panelDisplay[i].setBackground(Color.white);
boardPanel.add read more about NoClassDefFoundError; Exception in thread "main"


Message from Crackles McFarly
Most recent post: 7/18/2007
4 authors and 5 replies.

I'd like to take a crack at some simple encryption, like2 or 4 bit.
Any place I could go for some help?

Can I use an open source language/compiler?

I do not have enough $$ yet.
thanks
a lot

Yours Truly,
Crackles R. MCFARLY
Associates Degree in Air Quality and Pollen Studies
Certified Air Quality Specialist 'X7 Station: Fulton County, Georgia' read more about Want to learn to code an Encryption program. Where to go?


Message from Shaffer
Most recent post: 7/5/2007
4 authors and 4 replies.

Hello,
I find it amazing how it is just almost impossible for a JAVA beginner
to find a compiler out there / use one that's found, moreover, using
their manuals. So please, just tell me what compiler you use and how
to get it to work, in the most basic manner.
I'd really appreciate that, thanks!

Finding a free compiler for any other free language is fine, but in
JAVA it just gets so complicated.
Thanks so much,
Shaffer. read more about Compiling JAVA


Message from Mr. X.
Most recent post: 7/4/2007
2 authors and 5 replies.

Hello,
I have looked for JINI examples,
and found them too complicated ones,
so I do not know where to start.

Besides there are several problems after install JINI 2.1 (starter kit),
and I'd like some answers to following, too, please.
1. In eclipse I do : import net.jini ... and the options are only :
net.jini.security.* and net.jini.security.policy.*
What should I do on Eclipse, and what should I declare on the class-path.
2. I do not know whether JRE 1.6 is fine, for using JINI,
or should I use only JDK 1.2 ?
3. Should I start some server side - How can I do that ?
4. Some of examples I have found on the Internet does not even compile.
i.e. :
http://www.enete.com/noel/nuggets_jini/index.html
if I search into :
http://www.enete.com/noel/nuggets_jini/pages/StartJiniSummary.html
but when running "r2" on "\nuggets \pages \examples \StartJini",
I got the message :
Exception in thread "main" JAVA.util.zip.ZipException: The system cannot
find the path specified
at JAVA.util.zip.ZipFile.open(Native Method)
at JAVA.util.zip.ZipFile.<init>(Unknown Source)
at JAVA.util.jar.JarFile.<init>(Unknown Source)
at JAVA.util.jar.JarFile.<init>(Unknown Source)

The situation is :
There is a server, keeps a whiteboard.
On the whiteboard any users can join, and put their own message
(or simple graphics, or whatever).
Any users on other computers, that joined the group can put it's read more about JINI - some questions, and example of chat.


Message from Mr. X.
Most recent post: 6/29/2007
4 authors and 5 replies.

Hello,
I want to know about JINI technology,
what its pros and cons, and how can I use that technology
(using Eclipse SDK version 3.2.2).
Is JINI a good alternative for using databases ?

Need samples / tutorials, please.

Thanks :) read more about code sample for JINI


Message from Mr. X.
Most recent post: 6/25/2007
2 authors and 2 replies.

Hello.

I need free database for a simple product (freeware)

I think MySql is fine, but I do not know if it is good for Hebrew,
and if it is freeware.

Any suggestion,
and where can I find some, please.

Thanks :) read more about need free database for using my product.


Message from Mr. X.
Most recent post: 6/23/2007
4 authors and 5 replies.

Hello,
I want to install full JAVA installation, with environment & server.
I want some details about how installing eclipse & tomcat
(on windows platform, and also on unix platform (knoppix)).

Need some details what how to install, and some links, please.
(Is not any some way to do one installation, or I should do that on the hard
way ...)

Thanks :) read more about JAVA installation


Message from Jack Dowson
Most recent post: 6/16/2007
3 authors and 3 replies.

Hello,Everybody:
I'm new to JAVA.I'm now confused by the sequence of initializing
static members of a class.
wrote in message for testing:

class InitSequenceClassA{
static int i=0;
public InitSequenceClassA(){
i=15;
}
public InitSequenceClassA(int i){
this.i=i;
}
static void increment(){
i++;
}
}
class InitSequenceDemo{
public static void prt(String s){
System.out.println(s);
}
InitSequenceClassA isc = new InitSequenceClassA(10);
static InitSequenceClassA isc1, isc2;
static{
prt("isc.i=" + isc1.i+ "isc2.i=" + isc2.i);

isc1 = new InitSequenceClassA(27);
prt("isc1.i=" + isc1.i + "isc2.i=" + isc2.i);

isc2 = new InitSequenceClassA(15);

prt("isc1.i=" + isc1.i + "isc2.i=" +isc2.i);
}
public static void main(String[] args){
InitSequenceDemo d= new InitSequenceDemo();
prt("d.i=" + d.isc.i);

prt("isc.i=" + isc1.i+ " isc2.i=" + isc2.i);
isc1.increment();

prt("isc.i=" + isc1.i+ " isc2.i=" + isc2.i);
prt("d.i=" + d.isc.i);
}
}Compile and excute this class we'll get output as follow:

isc.i=0isc2.i=0
isc1.i=27isc2.i=27
isc1.i=15isc2.i=15
d.i=10
isc.i=10 isc2.i=10
isc.i=11 isc2.i=11
d.i=11

The first three lines of the output,that is
isc.i=0isc2.i=0
isc1.i=27isc2.i=27
isc1.i=15isc2.i=15

What happend to create the first three lines?
I think it might be:
1.the loading of class InitSequenceDemo;
2.after the loading of method main,the creating of object d;
which is r read more about Help!Maybe it's really simple for you?


Message from Jim Michaels
Most recent post: 6/16/2007
3 authors and 10 replies.

drawframe = new JFrame("4D Object Viewing Area");
drawframe.setSize(xMax+25+1,yMax+25+1);
drawframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
drawPanel = new JPanel();
//drawPanel.setSize(drawPanel.getMaximumSize());
drawPanel.setSize(xMax+1, yMax+1);
drawPanel.setBackground(Color.black); drawPanel.setVisible(true);
drawframe.getContentPane().add(drawPanel);
drawframe.addComponentListener(new ComponentListener() {
// This method is called after the component's size changes
public void componentResized(ComponentEvent evt) {
Component c = (Component)evt.getSource();

// Get new size
Dimension newFrameSize = c.getSize();
Dimension newDrawSize = new
Dimension((int)newFrameSize.getWidth()-10,
(int)newFrameSize.getHeight()-30);
drawPanel.setSize(newDrawSize);
drawPanel.repaint();
}
});C:\prj\hyprcube3\src>JAVAc Hyper3.JAVA
Hyper3.JAVA:653: <anonymous Hyper3$1> isn't abstract and doesn't
override abstract method componentHidden(JAVA.awt.event.ComponentEvent)
in JAVA.awt.event.ComponentListener
drawframe.addComponentListener(new ComponentListener() {
^
1 errorit is complaining about the addComponentListener. I got this from
http://epis read more about overriding abstract method?


Message from Jim Michaels
Most recent post: 6/12/2007
3 authors and 13 replies.

--------------020308030804030402070709


source attached.

I have looked through several google articles and found no help that could
relate. braces are matched.

C:\prj\hyprcube3\src>JAVAc Hyper3.JAVA
Hyper3.JAVA:1182: 'class' or 'interface' expected
synchronized void rotate4D() { //calculate
^
Hyper3.JAVA:1288: 'class' or 'interface' expected
public Graphics offgraphics = null;
^
Hyper3.JAVA:1289: 'class' or 'interface' expected
public Dimension offscreensize = null;
^
Hyper3.JAVA:1294: 'class' or 'interface' expected
public synchronized void update(Graphics g) {
^
Hyper3.JAVA:1382: 'class' or 'interface' expected
} //close class Hyper3
^
Hyper3.JAVA:1387: 'class' or 'interface' expected
^
6 errors

C:\prj\hyprcube3\src>

--

------------------------------------
Jim Michaels
for email, edit the address

RAM Disk is *not* an installation method.

--------------020308030804030402070709

Content-Disposition: inline;
filename="Hyper3.JAVA"

import JAVAx.swing.*;
import JAVAx.swing.event.*;
import JAVA.awt.*;
import JAVA.awt.color.*;
import JAVA.awt.event.*;
import JAVA.lang.String;
import JAVA.io.*;
import JAVA.math.*;
//import Vector4D;
//import Vertex4D;
//import org.xml.sax.ext.LexicalHandler; //fails. ugh.
/*
4D object rotator: This program allows you to view 3D shadows of 4D
objects if you've red-blue 3d glasses (c read more about class or interface expected


Message from Jim Michaels
Most recent post: 6/12/2007
3 authors and 5 replies.

class Vertex4D {
public double x, y, z, w;
Vertex4D() {
x = 0; y = 0; z = 0; w = 0;
}
Vertex4D(double newX, double newY, double newZ, double newW) {
x = newX; y = newY; z = newZ; w = newW;
}
public double getX() {return x;}
public double getY() {return y;}
public double getZ() {return z;}
public double getW() {return w;}
public void setX(double newX) {x = newX;}
public void setY(double newY) {y = newY;}
public void setZ(double newZ) {z = newZ;}
public void setW(double newW) {w = newW;}
}

class text {
Vertex4D[] v;
public boolean done, rotate = false, printMode, objectLoaded=false;
Thread th;

text() {
System.out.println("text constructor");
v = new Vertex4D[20];
if (v == null) {System.out.println("v=null!"); return;}
v[0].setX(0);
}

public static void main(String args[]) {
System.out.println("main");
//complains about static context of v if I put the above code
in here & get rid of line below.
new text();
}
}
C:\prj\hyprcube3\src>JAVA text
main
text constructor
Exception in thread "main" JAVA.lang.NullPointerException
at text.<init>(text.JAVA:41)
at text.main(text.JAVA:47)

Exception at the v[0].setX(0); line basically. this should not be happening.
I cannot see what I'm doing wrong here. I do not want to set the size read more about Class instatiation via new is null?


Message from Jim Michaels
Most recent post: 6/9/2007
4 authors and 17 replies.

import JAVA.lang.String;
...
public void paint(Graphics g) {
Graphics2D comp2d = (Graphics2D)g;
Dimension appletSize = this.getSize();
appletsize_x = appletSize.width;
appletsize_y = appletSize.height;
String sx=String.format("%d", appletsize_x);
String sy=String.format("%d", appletsize_y);
g.drawString(sx, 200,30);
g.drawString(sy, 200,60);
g.setColor(Color.red);
g.fillOval(x_pos - radius, y_pos - radius, 2*radius, 2*radius);
}
...
}

ballapplet.JAVA:101: cannot resolve symbol
symbol : method format (JAVA.lang.String,int)
location: class JAVA.lang.String
String sx=String.format("%d", appletsize_x);
^
ballapplet.JAVA:102: cannot resolve symbol
symbol : method format (JAVA.lang.String,int)
location: class JAVA.lang.String
String sy=String.format("%d", appletsize_y);
^
2 errors
--

------------------------------------
Jim Michaels
for email, edit the address

RAM Disk is *not* an installation method. read more about how do I use String's format? not working on XP


Message from Tom Wu
Most recent post: 6/8/2007
2 authors and 3 replies.

I want to create file for input but I need to check if file exist if not I
want to tell end user file isn't exist
Can you give some advise?
thanks
To read more about FileInputStream


Message from Jim Michaels
Most recent post: 6/7/2007
3 authors and 6 replies.

C:\prj\JAVA\swing>JAVA SwingDemo
Exception in thread "main" JAVA.lang.NoClassDefFoundError: SwingDemo

import JAVAx.swing.*;

class SwingDemo {
SwingDemo() {
//new top-level container
JFrame jfrm=new JFrame("A simple Swing program");
//jfrm.setTitle("FirstFrame");
jfrm.setSize(275,100); //set container's size'
//stop prograzm when user clicks close box
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//create a text-based label.
JLabel jlab=new JLabel(" Swing powers the modern JAVA GUI.");
//add label to the content pane
jfrm.getContentPane().add(jlab);
//display the frame
jfrm.setVisible(true);
}
public static void main(String args[]) {
//create the frame on the event dispatching thread.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new SwingDemo();
}
});
}
}I get this error with every swing application I compile. tried it with
2 different versions of JAVA compiler (including the latest) and their
associated JAVA classlibs set in the environment variable CLASSPATH.
--

------------------------------------
Jim Michaels
for email, edit the address

RAM Disk is *not* an installation method. read more about simple swing app from book gives JAVA error


Message from Armando Padilla
Most recent post: 5/11/2007
2 authors and 2 replies.

Hi all, I was wondering if anyone knew how to send a pre made soap
envelop across the wire. I looks at the JAVAx.xml.soap API (application programming interface)but that
creates the envelop for you. Any suggestions?

Thanks in advance. read more about JAVA soap client


Message from philae
Most recent post: 5/8/2007
3 authors and 3 replies.

Hi everyone, I'm new to JAVA and'd like to know what do I need to
install in my computer to start learning.The compiler + interpreter
issues seemed very confusing to me....can you advice some document me
to read about this compiler + interpreter topics??(how to get started,
what about IDE etc.) read more about JAVA newbie


Message from Marzena
Most recent post: 5/7/2007
2 authors and 2 replies.

Hi, I am making navigation in JAVA3d scene. I am able to navigate
observer ,but I have problem with navigation camera around
sphere,where middle is the middle of objects on the scene,which is far
away from viewplatform (x=0,y=0,z=0). I need to move around
camera,where center is a point (for eg. X=5,y=4,Z=2) . Every transform
I make it is make relative to center of viewplatform(x=0,y=0,z=0).
Anybody can help me? read more about JAVA3D move camera around sphere


Message from Bernard fait la java
Most recent post: 5/7/2007
2 authors and 2 replies.

Pour sortir de la semoule et bien comprendre,

poucez vous me donner des pistes pour programmer un code pour créer un
programme qui simule un lancer de deux dés, et qui compte combien de lancers
sont nécessaires avant d'obtenir un double six. (voir la méthode
Math.random( ) dans la référence)Merci de vos avis

Bernard read more about Petit coup de pouce JAVA


Message from Fanta-Girl
Most recent post: 5/4/2007
2 authors and 3 replies.

Mon premier programme JAVA.

Je suis en licence de communication et on attaque le JAVA.
Bon, rien d'extraordinaire, il faut acquérir la base.
Par contre le temps me manque et mon pc aimerait prendre sa retraite. lolJe viens vers vous pour comprendre vite, bien, avec les meilleurs références
:)
Mon expérience ma appris qu'il y a des personnes très compétentes sur les
forums,
et bien souvent, des ressources plus que merveilleuses et pratiques peuvent
être partagées.Je vais déjà devoir configurer le path de REALJ que j'utiliserai pour
programmer.

Ensuite, notre excellent professeur nous a fait un récap dans les règles de
l'art, cela en ligne puisqu'il s'agit de cours en ligne ... Il va falloir
trier cela et mes questions vont fusées ;-)En attendant, laissez moi vous amuser avec notre 1er exercice de groupe :)

Ecrire un programme JAVA qui affiche et compare deux entiers passés en
paramètres (les paramètres passés sur la ligne de commande sont accessibles
via args[0], args[1], . et leur nombre est args.length).Voilà, je suis preneur de tous vos conseils, infos, tuto, indications,
pistes, et meme encouragement lol :)

Bonne journée
Bernard read more about Prise en main


Message from KenStahl
Most recent post: 4/29/2007
4 authors and 6 replies.

I have written a small program that looks like this:

import JAVA.lang.*;
import JAVA.util.*;
import JAVA.text.*;class datetest {
public static void main(String args[]){
Date nd = null;
String ds = "01/01/1970 00:00:00 GMT";
String df = "MM/dd/yyyy HH:mm:ss zzz";

SimpleDateFormat f = new SimpleDateFormat(df);

try {
nd = f.parse(ds);
}
catch (Exception e){
System.out.println(e.toString());
}
System.out.println("Date: " + nd);
}
}

When I run this program the output is: Date: Wed Dec 31 19:00:00 EST 1969

I want it to print out the literal time that I supplied so it'd be: Thr
Jan 1 00:00:00 GMT 1970

I can not set the timezone in the date object, so what'd I have to do to
make it come out right. I suspect that it'd involved a Calendar object,
but how do I move the time from the f.parse(ds) into a Calendar object that
is set up for GMT? read more about Printing out dates


Message from Jeremy
Most recent post: 4/17/2007
2 authors and 2 replies.

What's the best way to ask questions in the group. I have noticed that no
matter how I ask questions, I do not get any responses.. so I'd like to
know if there is any valuable information on how to ask question in the
group. read more about Question


Message from Peter
Most recent post: 4/15/2007
2 authors and 6 replies.

I wanted to find out how high my computer will count (by increments of
'1'). Since counting by '1' takes an extended amount of time, I thought
I'd start my program at a high number.

The program is capable of counting higher than 2^33, however, if I tell
the program to start at a number of 2^33 it gives me an error.

A long can count up to 2^64 but the compiler wont allow me to start
counting at that high of a number.Does anyone know why?Here is a copy of my program:

/*
*
*This program will count
*
*/


class count {

public static void main (String args[]){

long count; //specifies count size

for (count=2147597261; ; count++){ // increments counter by 1

System.out.println("\t\t The count is: " + count); // outputs count }

}

} read more about Starting a counting program from a high number


Message from 001
Most recent post: 4/7/2007
3 authors and 3 replies.

I have a class with a static variable in it and now I want it to be accessed
from within a static method, but that method has an argument with the same
name. When referring to an object there is the 'this' keyword, but what to
do when you refer to the class itself?! read more about Little problem with class-variable acces


Message from Andrew Brampton
Most recent post: 3/31/2007
2 authors and 2 replies.

Hi,
I have encoutered a design problem that I'm unsure how to solve in a neat way.

I have a class called Ranges, which represents a set of numerical ranges,
such as [0-10] [30-50], etc. And I can OR different Range instance together
to work out the overlaps.

class Ranges {
// Returns the overlapping regions of the two ranges
public Ranges overlap ( Ranges r ) {
Ranges ret = new Ranges();
//do something
return ret;
}
}

Now I have a RangeCounts class, which does a similar thing, but assigns a
value to these ranges., such that [0-10 val 1] [30-40 val 2] [40-50 val 1].
Now this works in a very similar way to Ranges, and infact extends Ranges.

class RangeCounts extend Ranges {
// Does exactly the same as the parent, thus not defined
//public Ranges overlap ( Ranges r ) {}
}

Now the problem is, the overlap method in RangeCounts is the exact same code
as Ranges, thus I do not overload it. BUT I want the overlap method to return
a new RangeCounts object, not a Ranges object. Now I can make this happen by
overloading overlap, and duplicating the code. OR I can create another
method that returns a new instance of that class, and make sure both Ranges
and RangesCount implement this method. That way in Ranges.overlap, it'll
call this method instead of doing "new Ranges()".

But both ways seem ugly to me.

How do people normally solve this problem? Hopefully I have explained it well
enough. read more about Return instance of subclass


Message from tony_se
Most recent post: 3/31/2007
2 authors and 2 replies.

I have this class:
public class Say {
public static int say(int i) {
System.out.println("* Say: " + i);
return i;
}

public static int say2(String msg) {
System.out.println("** " + msg);
return 1;
}
}

and I created a function in Derby:
create function say2(msg varchar(50)) returns integer
parameter style JAVA no sql language JAVA
external name 'Say.say2';

but when I want to use it, error occurs:
ERROR 42X50: No method was found that matched the method call
Say.say2(JAVA.lang
.String), tried all combinations of object and primitive types and any
possible
type conversion for any parameters the method call may have. The
method might e
xist but it isn't public and/or static, or the parameter types are
not method I
nvocation convertible.

And I created another function:
create function say(i integer) returns integer
parameter style JAVA no sql language JAVA
external name 'Say.say';

It works fine.

I have tried hard to figure it out but failed. Can anybody help me?

Thank you in advance!!! read more about function in derby[beginner]


Message from Jeremy
Most recent post: 3/30/2007
3 authors and 4 replies.

As you can see, My program compiled and run, but I got a warning on that,
and I was wondering what that means? In my program, I used Stringtokenizer
and stack to reverse a string, and I think it has to do with stack?

also how can I recompile with -Xlint ?

Note:StackReverse.JAVA uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

Process completed. read more about Compiler warning Question


Message from fugtruck
Most recent post: 3/26/2007
2 authors and 2 replies.

<br><font size=2 face="sans-serif">There is a particular concept that I
am having a bit of trouble understanding regarding creating new instances
of a class. &nbsp;I'll use the ArrayList class as an example, but could
be any class. &nbsp;For example:</font>
<br>
<br><font size=2 face="sans-serif">List myList1 = new ArrayList();</font>
<br><font size=2 face="sans-serif">ArrayList myList2 = new ArrayList()?</font>
<br>
<br><font size=2 face="sans-serif">What'd be the difference between
myList1 and myList2? &nbsp;Or, when'd it be appropriate to use one
method over the other? &nbsp;My understanding is that myList2 could be
used anywhere an instance of type List'd be expected, correct?</font> read more about Newbie question


Message from Jim Michaels
Most recent post: 3/21/2007
2 authors and 6 replies.

the default XP box has 1.4.2_03 on it. however, my SDK and dev env is
1.5.0_09.

how can I make this applet work on the average machine without an upgrade?

//draw random lines all over the screen
import JAVA.awt.*;
import JAVAx.swing.*;

public class firstprogram extends JAVA.applet.Applet {
public void init() {
//Color background = new Color(0, 0, 0);
setBackground(Color.black);
}

public void paint(Graphics screen) {
Graphics2D comp2d = (Graphics2D)screen;
Dimension appletSize = this.getSize();
int xsize = appletSize.width;
int ysize = appletSize.height;
int x, y;
int xto = (int)((xsize-1)*Math.random());
int yto = (int)((ysize-1)*Math.random());
for (int i=0; i<2000; i++) {
x = xto;
y = yto;
xto = (int)((xsize-1)*Math.random());
yto = (int)((ysize-1)*Math.random());
Color c=new Color((int)(Math.random()*255), (int)(Math.random()*255),
(int)(Math.random()*255));
comp2d.setColor(c);
comp2d.drawLine(x, y, xto, yto); //draw from where you drew last
}
}
} read more about making this applet work on XP


Message from Bob Wright
Most recent post: 3/16/2007
5 authors and 6 replies.

Does Sun have an archive section?

I am looking for JAVA jdk-1.2 to go with a book on JAVA.
Can anyone tell me where I may get that version?

Bob read more about JAVA Version


Message from Mangiafuoco
Most recent post: 3/13/2007
2 authors and 2 replies.

Hi all,
i'm looking for a cvs client with a graphic history visualizazion. For each
people in my team I need to *view* in a graphical way the segments of code
modified.
Do you know a software for my needs?

Thanks in advance,

Roberto read more about CVS graphic History visualization


Message from garrett
Most recent post: 3/9/2007
4 authors and 7 replies.

Hi,
There are some applets that I execute from the web which I want you to
modify how they are displayed on my computer. This changes involves making
fonts larger or creating hot keys that will allow me to input certain text
strings into certain dialog boxes. This might mean I'd modify my local
JAVA interpreter. Am I right? If I modify the interpreter, will it still
allow me to execute applets from the web? Another question is how do I
modify this (jre?).
I appreciate any advice
Garrett read more about Modify JAVA interpreter?


Message from Shane
Most recent post: 3/5/2007
2 authors and 3 replies.

Hi
I am really new to JAVA. I've created an ArrayList<String> and want to
sort the elements. I tried using toArray(), but I cannot grok the docs I
found at
http://JAVA.sun.com/j2se/1.4.2/docs/api/JAVA/util/ArrayList.html#toArray()

This seems like it should be trivial but I am just not 'getting it'

TIA read more about Sorting an ArrayList[code][/code]


Message from Richard
Most recent post: 2/28/2007
2 authors and 2 replies.

Hello,
I'm trying to write JAVA code that will create a single audio file
(eg .avi or .mpg) that produces a sequence of DTMF tones, like that used on
a telephone, corresponding to what the user types in. Eg if they want to
dial '245833', they'd enter each digit 2-4-5-8-3-3 into the online form,
hit enter, and the script'd create a single file that when run outputs
the corresponding DTMF tone sequence. Is there a JAVA function that can do
this? or part of this? Otherwise what language'd you suggest'd be
best to implement this function on eg C#, .Net, etc?

Regards,

Richard read more about which JAVA audio function to use?


Message from petoeter
Most recent post: 2/24/2007
2 authors and 2 replies.

Hi,

The aim is to write some code so , starting from an applet, the user
can a make a choice (by radio buttons and an OK button), generate
different frames.
Hereby my (simpified) code. What's wrong? Thanks,
(as a am a novice, all suggestions are wellco