Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] JCreator + Java == Error!

Started by Alpha_ProgDes Dec 28, 2003 at 4:19 PM 10 replies 1.3k views
Original Post
Alpha_ProgDes
Alpha_ProgDes
this be my code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class TriApplet extends JApplet implements ActionListener {


	double side1, side2, long_side;

	JLabel side1Label, side2Label;
	JTextField side1Field, side2Field;
	JButton calculate;

	public void init() {
		Container c = getContentPane();
		c.setLayout(new FlowLayout() );

		side1Label = new JLabel("Length of First Side of Triangle: ");
		c.add(side1Label);
		side1Field = new JTextField (10);
		side1Field.setEditable(true);
		c.add(side1Field);

		side2Label = new JLabel("Length of Second Side of Triangle: ");
		c.add(side2Label);
		side2Field = new JTextField (10);
		side2Field.setEditable(true);
		c.add(side2Field);

		calculate = new JButton("Press to calculate the hypotenuse: ");
		calculate.addActionListener(this);
		c.add(calculate);
	}


	public void actionPerformed(ActionEvent e){
		side1 = Double.parseDouble(side1Label);
		side2 = Double.parseDouble(side2Label);
		long_side = hypotenuse(side1, side2);
	}

	public double hypotenuse (double h_side1, double h_side2){
		double side3_sq = h_side1 * h_side1 + h_side2 * h_side2;
		double h_hypotenuse = Math.sqrt(side3_sq);
		return h_hypotenuse;
	}
}
and this is my error:
Unexpected Signal : EXCEPTION_FLT_STACK_CHECK (0xc0000092) occurred at PC=0xC2D1
52
Function=[Unknown.]
Library=(N/A)

NOTE: We are unable to locate the function name symbol for the error
      just occurred. Please refer to release documentation for possible
      reason and solutions.


Current Java thread:

Dynamic libraries:
0x00400000 - 0x00408000         C:\j2sdk1.4.2_03\bin\javac.exe
0x77F50000 - 0x77FF9000         C:\WINDOWS\System32\ntdll.dll
0x77E60000 - 0x77F45000         C:\WINDOWS\system32\kernel32.dll
0x77DD0000 - 0x77E5B000         C:\WINDOWS\system32\ADVAPI32.dll
0x77CC0000 - 0x77D35000         C:\WINDOWS\system32\RPCRT4.dll
0x77C10000 - 0x77C63000         C:\WINDOWS\system32\MSVCRT.dll
0x00280000 - 0x002F3000         C:\DOCUME~1\Clothere\LOCALS~1\Temp\cfb1.tmp
0x77340000 - 0x773CB000         C:\WINDOWS\system32\COMCTL32.DLL
0x77C70000 - 0x77CB0000         C:\WINDOWS\system32\GDI32.dll
0x77D40000 - 0x77DCD000         C:\WINDOWS\system32\USER32.dll
0x71B20000 - 0x71B31000         C:\WINDOWS\system32\MPR.DLL
0x771B0000 - 0x772CA000         C:\WINDOWS\system32\OLE32.DLL
0x77120000 - 0x771AB000         C:\WINDOWS\system32\OLEAUT32.DLL
0x71AD0000 - 0x71AD8000         C:\WINDOWS\System32\WSOCK32.DLL
0x71AB0000 - 0x71AC5000         C:\WINDOWS\System32\WS2_32.dll
0x71AA0000 - 0x71AA8000         C:\WINDOWS\System32\WS2HELP.dll
0x76390000 - 0x763AA000         C:\WINDOWS\System32\IMM32.DLL
0x629C0000 - 0x629C8000         C:\WINDOWS\System32\LPK.DLL
0x72FA0000 - 0x72FFA000         C:\WINDOWS\System32\USP10.dll
0x08000000 - 0x08138000         C:\j2sdk1.4.2_03\jre\bin\client\jvm.dll
0x76B40000 - 0x76B6C000         C:\WINDOWS\System32\WINMM.dll
0x5CD70000 - 0x5CD77000         C:\WINDOWS\System32\serwvdrv.dll
0x5B0A0000 - 0x5B0A7000         C:\WINDOWS\System32\umdmxfrm.dll
0x10000000 - 0x10007000         C:\j2sdk1.4.2_03\jre\bin\hpi.dll
0x009C0000 - 0x009CE000         C:\j2sdk1.4.2_03\jre\bin\verify.dll
0x009D0000 - 0x009E9000         C:\j2sdk1.4.2_03\jre\bin\java.dll
0x009F0000 - 0x009FD000         C:\j2sdk1.4.2_03\jre\bin\zip.dll
0x76C90000 - 0x76CB2000         C:\WINDOWS\system32\imagehlp.dll
0x6D510000 - 0x6D58C000         C:\WINDOWS\system32\DBGHELP.dll
0x77C00000 - 0x77C07000         C:\WINDOWS\system32\VERSION.dll
0x76BF0000 - 0x76BFB000         C:\WINDOWS\System32\PSAPI.DLL

Heap at VM Abort:
Heap
 def new generation   total 576K, used 551K [0x10010000, 0x100b0000, 0x104f0000)

  eden

****************
Another exception has been detected while we were handling last error.
Dumping information about last error:
ERROR REPORT FILE = (N/A)
PC                = 0x00c2d152
SIGNAL            = -1073741678
FUNCTION NAME     = (N/A)
OFFSET            = 0xFFFFFFFF
LIBRARY NAME      = (N/A)
Please check ERROR REPORT FILE for further information, if there is any.
Good bye.
Press any key to continue...
 
a) can anyone figure out, what''s wrong? as far as i know, i coded it correctly. b) can someone be nice enough to compile it and tells me if it works? (i think it''s JC messing up, but not sure) c) can someone recommend an easy to install Java IDE/compiler? (actually i''ll check the thread for that. but to my knowledge none of the posts easy anything about an easy install....) thanks!
Beginner in Game Development?  Read here. And read here.  
Julio
Julio
get a new computer.

My Homepage

Some shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
Fase
Fase
I'm not sure about the error, it looks like something with the virtual machine.
to find the error, try catching it. It usualy gives more information:

void function_where _things_get_screwed()
{
try
{
do_stuff();
even_more_so();
}
catch(Exception e)
{
e.printstacktrace();//Or something similar.
}
finally
{
do_stuff_that_always_has_to_be_done();
}
}


I can recommend the Netbeans IDE(www.netbeans.org). I've worked with it and it worked like a charm.

Greetz,

Mike


Look at all the pretty colours!

[edited by - Fase on December 28, 2003 5:34:52 PM]
Look at all the pretty colours!
nonnus29
nonnus29
It doesn''t compile because of here:

side1 = Double.parseDouble(side1Label);
side2 = Double.parseDouble(side2Label);

Your trying to parse a Double from a JLabel - doesn''t work. You could try using JTextComponent.getText() which returns a string from the JTextField (JTextField is a subclass of JTextComponent) then Double.parseDouble(String). Hope that helps.
Alpha_ProgDes
Alpha_ProgDes
thanks nonnus!
after an hour of commenting out code.
i came to that conclusion myself

so now i''m going to try out your suggestion.
(though it''s funny the book that i''m using, C How to Program by Deitel & Deitel [it has a C++ and Java section] doesn''t have that in their book. but they expect me to get the input from the Textfields using what i''ve shown so far... i have no idea how though.)
Beginner in Game Development?  Read here. And read here.  
Alpha_ProgDes
Alpha_ProgDes

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class TriApplet extends JApplet implements ActionListener {


double side1, side2, long_side;

JLabel side1Label, side2Label;
JTextField side1Field, side2Field;
JButton calculate;

public void init() {
Container c = getContentPane();
c.setLayout(new FlowLayout());

side1Label = new JLabel("Length of First Side of Triangle: ");
c.add(side1Label);
side1Field = new JTextField (10);
side1Field.setEditable(true);
c.add(side1Field);

side2Label = new JLabel("Length of Second Side of Triangle: ");
c.add(side2Label);
side2Field = new JTextField (10);
side2Field.setEditable(true);
c.add(side2Field);

calculate = new JButton("Press to calculate the hypotenuse: ");
calculate.addActionListener(this);
c.add(calculate);
}


public void actionPerformed(ActionEvent e) {
String firstSide, secondSide;

firstSide = side1Field.getText();
secondSide = side2Field.getText();

side1 = Double.parseDouble(firstSide);
side2 = Double.parseDouble(secondSide);

long_side = hypotenuse(side1, side2);
showStatus("The hypotenuse is: " + Double.toString(long_side));
}

public double hypotenuse (double h_side1, double h_side2) {
double side3_sq, h_hypotenuse;

side3_sq = h_side1 * h_side1 + h_side2 * h_side2;
h_hypotenuse = Math.sqrt(side3_sq);

return h_hypotenuse;
}
}


does anyone see what's wrong with this code?
right now I'm downloading NetBeans... JC is acting funny and it doesn't give any error messages i can make heads or tails of.

[edited by - Alpha_ProgDes on December 29, 2003 5:41:21 AM]
Beginner in Game Development?  Read here. And read here.  
garazdawi
garazdawi
sooo much can be read from a the error code that the javac command gives you. You can even sometimes get the line where the error in syntax is.... assuming ofcourse that you have a syntax error and not a sem error...
garazdawi - 'I put the laughter back in slaughter'
nonnus29
nonnus29
1. When asking for help you should always describe the problem and provide the error message.

So... The applet compiles and runs fine. The problem could be that the latest JDK, 1.4.2 does not by default compile code that will run with outdated vms, namely the Microsoft vm that currently ships with Windows. To get your applets/applications to run on machines without requiring the user to install the latest JRE you must compile with the switch "-target 1.1" and limit your class use to AWT classes. But if you have jre 1.4 installed this won''t be a problem.
Alpha_ProgDes
Alpha_ProgDes
and with that advice ....here i go.

hopefully as you can see with applet i''m trying to have the user input two number in the TextFields and then use those numbers to find the hypotenuse using the method "hypotenuse".

now two things occur which i don''t understand.
when i compile the code without initializing side1, side2, and long_side, i get that crazy error message that''s in my first post. if i do initialize with decimal numbers it compiles ok. why is that?

secondly this is my new code....

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class TriApplet extends JApplet implements ActionListener{
double side1=1.1, side2=1.1, side3;
JLabel firstSide, secondSide;
JTextField firstField, secondField;
JButton calculate;

public void init(){
Container c = getContentPane();
c.setLayout(new FlowLayout());

firstSide = new JLabel ("Side 1");
c.add(firstSide);
firstField = new JTextField(15);
firstField.setEditable(true);
c.add(firstField);

secondSide = new JLabel ("Side 2: ");
c.add(secondSide);
secondField = new JTextField(15);
secondField.setEditable(true);
c.add(secondField);

calculate = new JButton("Press Here to Calculate Hypotenuse.");
calculate.addActionListener(this);
c.add(calculate);
// showStatus("The hypotenuse is: " + side3);

}

public void actionPerformed(ActionEvent e) {
String tSide1 = firstSide.getText();
String tSide2 = secondSide.getText();

side1 = Double.parseDouble(tSide1);
side2 = Double.parseDouble(tSide2);
side3 = hypotenuse(side1, side2);

}




public double hypotenuse (double oneSide, double twoSide) {
double c_squared = oneSide * oneSide + twoSide * twoSide;
double c_side = Math.sqrt(c_squared);
return c_side;
}
}

now when i compile this everything works fine until i click on the calculate button. i get this error message.

java.lang.NumberFormatException: For input string: "Side 1"
at java.lang.NumberFormatException.forInputString(NumberFormatException.
java:48)
at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1
207)
at java.lang.Double.parseDouble(Double.java:220)
at TriApplet.actionPerformed(TriApplet.java:37)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
86)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1839)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258
)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:245)
at java.awt.Component.processMouseEvent(Component.java:5100)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

i''m have j2sdk/jre 1.4.2 and i''m still working with JCreator LE v3.0.0 (i tried NetBeans but it said that it couldn''t load the jvm.dll.. bleh)

seeing that i''m learning this on my own, a little help wouldn''t hurt but in all seriousness i''m new to Java and this GUI stuff and half the time wonder things that work in C/C++ (like having it compile without initializing first, especially for input) doesn''t work.

anyway, thank you.
Beginner in Game Development?  Read here. And read here.  
Alpha_ProgDes
Alpha_ProgDes
well i FINALLY GOT IT TO WORK!!!

i was supposed to have

firstField.getText()
not
firstSide.getText()

silly me....

but anyway, i still would like an answer to those questions i have if someone could be so kind to answer...

if i''m defining a method definition, such as hypotenuse, why do i have to initialize the variables i plan to pass to it first?
examples:

double side1, side2, side3;
.
.
.
public void actionPerformed(ActionEvent e) {
String tSide1 = firstField.getText();

String tSide2 = secondField.getText();

side1 = Double.parseDouble(tSide1);
side2 = Double.parseDouble(tSide2);
side3 = hypotenuse(side1, side2);

showStatus("The hypotenuse is: " + side3);

}

public double hypotenuse (double oneSide, double twoSide) {
double c_squared = oneSide * oneSide + twoSide * twoSide;
double c_side = Math.sqrt(c_squared);
return c_side;
}
//excerpts from full code above



if i don''t initialize the variables i get the error i just posted. but if i do, then everything is ok. why is that?

and is there any way to code in Java like you would in C++? it seems like everything needs to be accessed through the GUI. so far it seems like a hassle, which is part of the reason why i don''t understand how people say that Java helps you code faster.

anyway, thank you for all the help.
Beginner in Game Development?  Read here. And read here.  
Aldacron
Aldacron
I''m a bit confused by what you''re saying. In your last example, you did not initialize the side variables, you declared them. Initializing them at declaration would look like:

double side1 = 0.0, side2 = 0.0, side3 = 0.0;

This is not required to compile. The code you have there should compile just fine. Also, in that snippet there''s no need to declare those as class members anyway. You can declare and initialize them in the actionPerformed method just as you did the 2 strings.

quote:

and is there any way to code in Java like you would in C++? it seems like everything needs to be accessed through the GUI. so far it seems like a hassle, which is part of the reason why i don''t understand how people say that Java helps you code faster.



And here I think you''re confused. Java syntax is very much like that of C++. If you aren''t using GUI components, then you don''t need to go through a GUI So I''m not sure what point is confusing you, but even in C++ if you are using a GUI API you still need to go through that API to get textfield input and other GUI events (think Win32 or XWindows). The difference is that C++ does not ship with a platform independent GUI library, but Java does.

I don''t know what you are using to learn the language, but you seem to be cloudy about what is going on. If you can buy it, Beginning Java 2 by Ivor Horton is an excellent book for learning Java. It''s around 1100 pages of text plus 5 or 6 appendices, goes at an easy pace, and covers a good bit of material at just the right depth, including several Swing topics. He walks you through the creation of a sketching program, which is quite fun to play with. I bought it a while back even though I had already been working with Java for a few years, simply because he gives some great tips.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.