| String Fraction to Number |
|
 |
Index ‹ java-programmer
|
- Previous
- 5
- JDBC DriverHello,
How can I find out which JDBC driver is available on my system? I
am working on a linux server. I am trying to learn JDBC programming and
am having problems about which JDBC driver to use.
Regards
Marmagya
- 7
- ClassDefNotFoundI'm having a lot of trouble trying to run small applications that have compiled
fine. No matter what I try attempting to execute any class file gives me this
message:
java -classpath "." TryWindow.class
Exception in thread "main" java.lang.NoClassDefFoundError: TryWindow/class
I've tried setting my class path the the current working directory in my
environment, specifying the current directory with the -classpath switch,
specifying "" with the class path switch, running it as an unprivileged
user, running it as root, and manipulating the permissions and the result
has been the same. I also rebooted to Windows and tried it with the
NetBeans ide. What am I doing wrong? According to what I have read
java should be able to find classes in the current working directory.
Here is the code for the example I tried:
import javax.swing.*;
public class TryWindow{
static JFrame aWindow = new JFrame("This is the Window Title.");
public static void main()
{
aWindow.setBounds(50, 100, 400, 150);
aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
aWindow.setVisible(true);
}
}
Thanks in advance.
Mitch_M
- 8
- Signed code runs using WebStart in 1.4 but not 1.5I have a signed application that runs flawlessly under WebStart in 1.4
JDKs/JREs (on WinXP/2K, Linux and MacOS X) that refuses to run under
WebStart in 1.5 JDKs (on both Windows and Linux; haven't tried on MacOS).
The error occurs when the certificate is validated (this is from 1.5.0_03):
java.security.cert.CeritificateException: Check leaf key usage failed in
certificate
at
com.sun.deploy.security.CertUtils.checkUsageForCodeSigning(CertUtils.java:102)
...
I've tried 1.5.0 (Windows & Linux) and 1.5.0_03 (Linux), with the same
error each time. I know of several others who have also been unable to
run my application under 1.5.0; I don't know of anyone who has been able
to run it under 1.5.0.
I'm using a code-signing certificate bought from Thawte. I've tried
using jarsigner from both 1.4 and 1.5, but get the same results each
time. From the exception, it seems likely that 1.5.0 doesn't believe
that the certificate used to sign the code can be used for code-signing,
but I don't know why it would come to this conclusion.
I've successfully run this app using WebStart under 1.4.2_01, 1.4.2_03
and 1.4.2_06, on Linux and WinXP/2K (ie these JDKs all successfully
validate the certificate used to sign the app and prompt the user as
expected), plus various Apple 1.4 JVMs.
Google hasn't been of any assistance, so any help would be greatly
appreciated.
Cheers,
Damian
- 8
- problem with methods on a bound classHi,
I've been fiddling around with JavaScript.pm, which is very cool, I have to
say, I've bound a class, and sucessfully bound an object, and i can read
from the object's properties, and execute it's getter/setter functions, but
for some reason i cannot get the object's methods to work..
here's a cleaned up version of what i've been testing with:
$js->bind_class(
name=>'Foo',
methods=>{
test => \&Foo::test
},
properties=>{
testy =>{
flags => JS_PROP_READONLY | JS_PROP_ACCESSOR,
getter => \&Foo::test_getter,
}
}
);
my $obj = new Foo();
$js->bind_object('obj', $obj)
(where package Foo has a 'test' method)
....
now in js: 'obj.testy' (the property) works fine, but 'obj.test()' (method)
just doesn't.. there seems to be no indication that it's successfully bound
(everything just says it's not defined).. getters and setters work, but
methods just don't seem to..
Any clues as to what's going on?
Dan
- 8
- Loading jdbc jars and classes in the application default classloader dynamically..In our application, the JDBC jar files are stored in pre configured
location. say c:\server\libs\1.jar, 2.jar
We don't want to include these jars file in the class path. However,
whenever, we receive a jdbc request, we want to be able to load all the
jars located in this location and then do the basic jdbc call
sequence...
e.g. Class.forname("com.mydriver.SQLServerDriver");
Connection conn = DriverManager.getConnection(
"jdbc:mydriver:sqlserver://sqlserver1:1433;DatabaseName=Mydb;User=****t;Password=*****"
);
How ca i do this?
I tried the following code but doesn't help... I keep getting the
java.sql.SQLException: No suitable driver error. After somedebugging, I
found that the Drivermanager uses some getCallerClassLoader and that
doesn't match the class loader of com.mydriver.SQLServerDriver.
How do i make the loading using the default class loader at the same
time including those jar files?
String x = "kjds";
File f = new File("D:/server/libs");
File[] jarFiles = f.listFiles(new ExtentionFilter("jar"));
URL[] urls = new URL[jarFiles.length+1];
int i=0;
for(;i< jarFiles.length;i++){
try{
urls[i] = jarFiles [i].toURL();
}catch(Exception ex){}
}
ClassLoader z = new URLClassLoader(urls,
x.getClass().getClassLoader());
try
{
//Class DriverClass =
z.loadClass("com.mydriver.SQLServerDriver");
//Driver dd = (Driver)DriverClass.newInstance();
// DriverManager.registerDriver(dd);
Driver x =
(Driver)Class.forName("com.actuate.actuatedd.jdbc.sqlserver.SQLServerDriver",
true, z);
String cnstr =
"jdbc:mydriver:sqlserver://sqlserver1:1433;DatabaseName=Mydb;User=****t;Password=*****"
Connection conn = DriverManager.getConnection( cnstr );
}
catch (Exception e)
{
e.printStackTrace();
}
- 10
- Generating excel sheets through JSPHi,
I have previously created excel sheets in JSP in weblogic, and i get
the result accurately.
I had used;
<%@ page contentType="application/vnd.ms-excel" import="java.sql.*"
language="java"%>
at the top of the page and,
<meta http-equi="Content-Type" content="application/vnd.ms-excel;
charset=iso-8859-1">
in the head tag of my page.
Now I'm using tomcat 5.5 and this is just not working....
Can someone help me out with this?
- 10
- Java developer needed (Open Source project)Java developer needed, pref. with socket prog exp
---------------------------------------------------
Programming Language :: Java Competent 6 Mo - 2 yr
Socket programming(Java):: Want to learn < 6 Months
Project page: http://freelancebot.sourceforge.net/
- 10
- struts or expresso or turbine?hi..
i've been reading the struts developer and it mentions that i want to
create a web application from scratch i should use either turbine or
expresso..
i'm looking for a free, main stream web framework, that can be used
with eclipse.
can anyone tell me about any of these and how they compare?
- 13
- Kodak v Sun; patent law gone all wrong?If in 1995 Sun Microsystems, Inc. changed the name of OAK to Java and
modified the code for the Internet, how did Sun infringe the patents
Kodak acquired from 'Wang' in 1997? What damning evidence did Kodak have
that in 1995, Sun incorporated the 'Khoyi' method, thereby infringed the
patents?
The "Khoyi patents", named after Dana Khoyi - an ex-Wang engineer,
"covered a method by which a program can get help from another computer
application to complete a task", which they claim is the way Java
operates and that Sun has therefore infringed the Khoyi patents..
Whose intellectual property is Java? Surely Java was patented in 1995,
just after the change? Were the Wang 'Khoyi' patents and Sun 'Java'
patents identical? I take it Wang patented their software years before
Sun did? Does anyone know what year?
If the two were identical or similar, isn't it possible that in a world
of 6,395,379,218 people, it is more than likely that two or more people
might have the same ideas? I find it difficult to believe that Sun
infringed Kodak's patents, but rather that Kodak got a little too
desperate given it's not doing so well in this 'digital' age and had to
lay off some 15,000 jobs worldwide a month ago "because of declining
demand for consumer film and colour photographic paper"..
How on earth can an eight member jury of lay people understand "patent
law" to deliberate and find in favour of Kodak? I don't understand how a
jury could possibly fathom the complexities of patent law, without any
background or education in the legal arena, and find in Kodak's favour?
There are a lot of questions that I have to things that don't add up,
like; Java is freely downloadable, so how can any jury find in favour of
Kodak who wanted damages of $1.06 billion in past royalties??
How did Kodak prove that Sun had access to its patents?
If Kodak is so sure that Sun infringed patents, why did it bother to
agree to the $92 million settlement? Surely they believed they would be
awarded $1.06 billion or even more..? accepting such a small amount (for
them) is silly, it sounds to me like they thought they wouldn't win..
This case is a perfect example why juries should NOT be involved in
patent suits.
Sun should not have settled the case, it should have seen the case
through and appealed the prospective travesty of justice..
Does anyone agree with me here? I'd be interested in other people's
opinions on this issue. A public debate, anyone?
- 14
- Store XML to databaseI have some details from a jsp page, that i will store in XML format,
using DOM. I have created this much and now i want to store this XML
file in the database. How to do this ? the xml is available as a stream
in my program.
help of any kind is appreciated
thanks in advance..
sarath
- 14
- Writing a generic InputBoxHi,
I wont tell my old way but I have rewritten my InputBox class as having
the following important snippets:
public class InputBox extends JDialog {
private ActionListener okAction;
public InputBox(ActionListener a, JFrame f, String label, String
title, String defaultText) {
okAction = a;
getMyOkButton().addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
okAction.actionPerformed(e);
dispose();
}
});
public String inputText() {
return control.getText();
}
}
Code uses it as follows
ActionListener okAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
myObject.setURLName(hyperlinkInputBox.getInputText());
} catch (Exception ex) {
Debug.LogException(this, ex);
}
}
};
hyperlinkInputBox = new UIInputBox(okAction, "Insert
Hyperlink",parentFrame,"URL:",null,300);
hyperlinkInputBox.setVisible(true);
I dislike having to make hyperlinkInputBox a private variable in the
calling class in order to reference it within the okAction
ActionListener. Same goes for myObject.
I guess it is not *too* shabby but can anyone improve my architecture?
thanks
Tim
- 14
- question concerning downcasthello guys,
Curiosity made me take a look at the tomcat 's implementation of the servlet
API.
The HttpServlet class, which can be subclassed by http servlets, contains
the "service" method that is invoked by the servlet container in order to
pass a web request to a particular servlet. The method accepts a
ServletRequest and ServletResponse object as arguments, and downcasts them
to HttpServletRequest and HttpServletResponse respectively and then calls a
"service" method implemented by the same class:
public void service(ServletRequest req, ServletResponse res) throws
ServletException, IOException
{
HttpServletRequest request;
HttpServletResponse response;
try {
request = (HttpServletRequest) req;
response = (HttpServletResponse) res;
} catch (ClassCastException e) { throw new ServletException("non-HTTP
request or response"); }
service(request, response);
}
}
How is it possible to do so, as the ServletRequest interface is more generic
than the HttpServletRequest (they have a hereditary relationship
HttpServletRequest== extends ServletRequest)?
TIA
- 14
- why it doest draw ???in the below short write
i try to write an Thread examle that try to draw lines in every second
from (0,0) to (x, y).
x and y are random between 0..255
with first come to tWork (Thread) it draws, but next second and next
seconds it doesnt do any thing.
g and gr are the same and initalized
i cheked them with this command :
System.out.println(gr.equals(g)); //it prints "true"
question is why it doesnt draw line after second 1 ?
polat
------------------------------------------------------------
package mypackage1;
import java.applet.*;
import java.awt.*;
import javax.swing.JButton;
class tWork extends Thread
{
Graphics gr;
public tWork(Graphics g)
{
gr = g;
System.out.println(gr.equals(g)); //it prints "true"
}
public void run()
{
int x, y;
while (true)
{
x = (int)(Math.random()*255);
y = (int)(Math.random()*255);
gr.drawLine(0, 0, x, y);
try
{
this.sleep(1000);
}
catch (Exception e) {}
}
}
}
public class Basla extends Applet
{
Thread t;
public Basla()
{
this.setSize(300,300);
}
public void paint(Graphics g)
{
t = new tWork(g);
t.start();
}
}
- 14
- [JSF] How to determine the WEB-INF path of the current web application?Hello everybody,
I'm new to the Java world writing my first Java web application with JSF 1.1
and Tomcat 5.5. I have the following problem:
I've created a Properties file and placed it in the WEB-INF directory of the
web application. The file contains several configuration options like
database parameters. I want to open this file within my web application
with a FileInputStream which I pass to the load() method of a Properties
object. Unfortunately I was unable to determine the path of the WEB-INF
directory of the current web application. I don't want to write the path
hard coded into the source code.
Maybe my way is not the correct "Java way" of solving this kind of problem
so I'm not only interested in an answer to my question but also in
suggestions how to solve this problem in a better way.
Thank you!
--
Sincerely
Sven Jacobs
- 14
- OOM detectionHi,
I'm looking for a way to detect that the JVM is reaching an out of
memory situation. But, I don't want to do this by means of catching
an OutOfMemoryError, because by that time the ship is already
sinking. I came up with a solution that uses the Reference Objects
API, but I don't know if it will do the job correctly.
Below is a demo. Please give me some feedback on this.
I also tried it out using a SoftReference, but then it gives an
OutOfMemoryError eventually. Is this behavior JVM dependent?
CC me,
Frank.
/*
* Run with: java -verbose:gc Test
*/
import java.lang.ref.*;
import java.util.*;
public class Test extends Thread {
private ReferenceQueue queue = new ReferenceQueue();
private Reference pr;
private static Stack stack;
public void run() {
while(true) {
Object o = new Object(); // dummy object
pr = new WeakReference(o, queue);
o = null;
try {
queue.remove(); // when our dummy object gets finalised we continue here...
}
catch(InterruptedException e) { }
System.out.println("OOM");
stack.clear(); // prevent OutOfMemoryError here...
}
}
public static void main(String [] args) {
stack = new Stack();
new Test().start();
while (true) {
stack.push(new Object());
}
}
}
|
| Author |
Message |
czupet

|
Posted: 2004-5-6 21:50:00 |
Top |
java-programmer, String Fraction to Number
Does anyone have an example of how to convert a String "26 1/2" to double 26.5 ?
Peter
Thank You
|
| |
|
| |
 |
VisionSet

|
Posted: 2004-5-6 22:33:00 |
Top |
java-programmer >> String Fraction to Number
"Peter" <email***@***.com> wrote in message
news:email***@***.com...
> Does anyone have an example of how to convert a String "26 1/2" to double
26.5 ?
double myDouble;
if(myString.equals("26 1/2")) myDouble = 26.5;
|
| |
|
| |
 |
Rob Shepherd

|
Posted: 2004-5-6 23:17:00 |
Top |
java-programmer >> String Fraction to Number
Peter wrote:
> Does anyone have an example of how to convert a String "26 1/2" to double 26.5 ?
>
> Peter
>
> Thank You
From the archives I dug out this method.
Last time i used it it worked (for my input data)
...
public static double fracNumericStringToDouble(String str)
{
double mydouble;
int firstpartindex = str.indexOf(" ");
String wholepart = str.substring(0, firstpartindex);
System.out.println(wholepart);
int secondpartindex = str.indexOf("/");
String numerator = str.substring(firstpartindex+1, secondpartindex);
System.out.println(numerator);
String denominator = str.substring(secondpartindex+1, str.length());
System.out.println(denominator);
mydouble = (Double.parseDouble(numerator) / Double.parseDouble(denominator));
mydouble += Double.parseDouble(wholepart);
return mydouble;
}
...
Please test
HTH
Rob
|
| |
|
| |
 |
antroy

|
Posted: 2004-5-6 23:43:00 |
Top |
java-programmer >> String Fraction to Number
Should perhaps alter it as follows to take into account whole numbers:
Rob Shepherd wrote:
...
> public static double fracNumericStringToDouble(String str)
> {
> double mydouble;
>
> int firstpartindex = str.indexOf(" ");
if (firstpartindex == -1) firstpartindex = str.length();
> String wholepart = str.substring(0, firstpartindex);
>
> System.out.println(wholepart);
> int secondpartindex = str.indexOf("/");
String numerator = "1";
String denominator = "1";
if (secondpartindex != -1){
numerator = str.substring(firstpartindex+1,
> secondpartindex);
> System.out.println(numerator);
>
denominator = str.substring(secondpartindex+1,
> str.length());
> System.out.println(denominator);
>
}
> mydouble = (Double.parseDouble(numerator) /
> Double.parseDouble(denominator));
> mydouble += Double.parseDouble(wholepart);
>
> return mydouble;
> }
> ...
>
> Please test
Again not tested, and could of course be cleaned up (the String
numerator = "1"; is a bit of a hack for example).
--
Ant...
|
| |
|
| |
 |
czupet

|
Posted: 2004-5-7 1:46:00 |
Top |
java-programmer >> String Fraction to Number
"VisionSet" <email***@***.com> wrote in message news:<i1smc.59$email***@***.com>...
> "Peter" <email***@***.com> wrote in message
> news:email***@***.com...
> > Does anyone have an example of how to convert a String "26 1/2" to double
> 26.5 ?
>
> double myDouble;
> if(myString.equals("26 1/2")) myDouble = 26.5;
Thanks for your help, but that's not exactly what I am looking for.
The String number can be any number with a fraction not just "26 1/2".
I am looking for a conversion function.
|
| |
|
| |
 |
groupsNO_SPAM

|
Posted: 2004-5-7 4:25:00 |
Top |
java-programmer >> String Fraction to Number
"VisionSet" <email***@***.com> wrote in message news:<i1smc.59$email***@***.com>...
> "Peter" <email***@***.com> wrote in message
> news:email***@***.com...
> > Does anyone have an example of how to convert a String "26 1/2" to double
> 26.5 ?
>
> double myDouble;
> if(myString.equals("26 1/2")) myDouble = 26.5;
Cute. You might also try the following (hackish) solution.
String l_input = "26 1/2";
String[] l_parts = l_input.split("(\\s)+");
double l_value = 0;
for(int i = 0; i < l_parts.length; i++) {
String l_fractionParts[] = l_parts[i].split("(\\D)+");
if(1 == l_fractionParts.length) {
l_value += Double.parseDouble(l_fractionParts[0]);
} else if(2 == l_fractionParts.length) {
l_value += Double.parseDouble(l_fractionParts[0]) /
Double.parseDouble(l_fractionParts[1]);
}
}
System.out.println(l_value);
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- jsp grid creationi want to use a grid in my front end using java. in this grid i want to
fetch the information from the database. can i make such a grid using
jsp.
if yes, can anybody tell me how?
ashutosh
- 2
- Assignment Linked List HelpCan some please implement a class called MyList to finish this off?
public class MyList<E extends Comparable<E>> extends List<E> {
}
----------------------------------------------------------------------------------------------------
It must be implemented with this List.java:
public abstract class List<E extends Comparable<E>> {
protected class Node<T extends Comparable<T>> {
protected Node(T data) {
this.data = data;
}
protected T data;
protected Node<T> next;
}
public abstract void insert(int index, E data) throws ListException;
public boolean isEmpty() { return head == null; }
public abstract E remove(int index) throws ListException;
public void reverse() { head = reverse(head, null); }
protected abstract Node<E> reverse(Node<E> curr, Node<E> prev);
public abstract int search(E data) throws ListException;
public int size() { return size; }
protected Node<E> head;
protected int size;
}
I need help for this assignment ......
Thanks...
- 3
- why "synchronized" with wait/notify ?I know the language requires it and what exaclty happens with
wait/notify.
BUT it appears that the whole wait notify protocol should work just as
well without acquiring a monitor lock on the target object...
I've read something about why we need to have a thread own a monitor on
the object (key) that is waiting on, something about race condition.
but icant wrap my head around it, could someone care to walk me through
it please using a scenario where it would not work as expected.
So why would this not work (logic- forget the illegal monitor state
execption)
ThreadA
|
|
key.wait() //suspend threadA and add to waitset of key
ThreadB
|
|
key.notifyAlll; //Wake up one of the threads in the waitset of key
Thanks
- 4
- traversing through arraysSuppose I've got the following code
public class EmployeeData
{
public static void main(String [] args)
{
String [] [] employeeInfo = { { "Alex" ,"Joe" , "James" , "Tom"}
,
{" Manager" , "Clerk" , "Analyst"
,"Manager"} };
double[] salary = { 2000 ,540 , 6321 ,1999.99};
// how do I traverse through that multidimensional array to display the
employee name and title and those who earn more than 2000
// I was trying to use a for loop ( int i = 0 ; i< employeeInfo.length ;
++i)
then use the if statement but it doesnot work ,
Anyone can help me on this problem
thanks
boen
- 5
- Help with XtagsI am using jakarta's xtags library. I have put the xtags.tld file
unser /WEB-INF and the taglibs-xtags.jar in the /WEB-INF in the lib
directory. I am using
java version 1.4.2-b28 and tomcat 4.1. IN my jsp i use the following
tags
<xtags:style xml="/test.xml" xsl="/article-html.xsl"/>
when i run the jsp, i do not get anything ..blank page... Rethere some
file i am missing...
any help would be appreciated.
THanks
Mohit
- 6
- Tomcat & SSL & a certificate generated by VerisignAttempting to SSL enable tomcat 4.04. Have implemented JSSE and SSL
works fine when I create a keystore with a self generated certificate.
keytool -genkey -alias tomcat -keyalg RSA -keystore .keystore
We now want to cutover using a production certificate. We create a
.cer file by accessing our production web site and export the
certificate to a .cer file.
then using the keytool we import the .cer file
keytool -v -import -file prod.cer -keystore .keystore
When we inspect the .keystore file using the -list switch we see the
certificate.
Now when we implement the .keystore in tomcat, only the original self
generated certificate is presented.
So, using the keytool we delete the original self generated
certificate so we are only left with the newly imported production
certificate.
When we implement this .keystore file with only the production cert,
the browser and tomcat fail to negotiate. Tomcat binds to port 8843
but the ssl negotiation is hosed.
Has anybody ever gottent tomcat & ssl to work with a non self
generated certificate? Can you please help?
Thanks,
email***@***.com
- 7
- Getting ResultSet From Cursor Too SlowAll,
I have a method that calls an Oracle Stored Procedure from an Oracle
Package. Everything works fine but the last two lines in my code below
where I get the Cursor from the procedure and cast it to a ResultSet is
a huge bottleneck. Does anyone have any ideas on how to make this
transition faster for large resultSets?
Thanks in advance.
Corey
ResultSet rs = null;
Result r = null;
String sql = "{call SECINQ.GetUsersBasic(?, ?, ?, ?, ?, ?, ?, ?," +
"?, ?, ?, ?, ?, ?, ?, ?," +
"?, ?, ?, ?, ?, ?, ?, ?," +
"?, ?, ?, ?, ?, ?, ?, ?, ?)}";
open();
CallableStatement call = (CallableStatement)con.prepareCall(sql);
call.registerOutParameter(1, OracleTypes.CURSOR);
call.setString(2, name1);
call.setString(3, name2);
call.setString(4, name3);
call.setString(5, name4);
call.setString(6, geid1);
call.setString(7, geid2);
call.setString(8, geid3);
call.setString(9, geid4);
call.setString(10, ssn1);
call.setString(11, ssn2);
call.setString(12, ssn3);
call.setString(13, ssn4);
call.setString(14, userId1.toUpperCase());
call.setString(15, userId2.toUpperCase());
call.setString(16, userId3.toUpperCase());
call.setString(17, userId4.toUpperCase());
call.setString(18, userId1.toLowerCase());
call.setString(19, userId2.toLowerCase());
call.setString(20, userId3.toLowerCase());
call.setString(21, userId4.toLowerCase());
call.setString(22, userId1);
call.setString(23, userId2);
call.setString(24, userId3);
call.setString(25, userId4);
call.setString(26, phone1);
call.setString(27, phone2);
call.setString(28, phone3);
call.setString(29, phone4);
call.setString(30, flName1);
call.setString(31, flName2);
call.setString(32, flName3);
call.setString(33, flName4);
call.setFetchSize(200);
call.execute();
rs = (ResultSet)call.getObject(1);
r = ResultSupport.toResult(rs);
- 8
- About JEditorPaneI wrote a plugin to NetBeans 5.0 which displays html pages in a
JEditorPane, when i clicked a file in explorer.
JEditorPane is in the topcomponent class.Also JTree(Explorer) in a
other topcomponent class.
I use setPage(URL url) method. But its not working properly.That means
the editor pane displays the html code of the file
But i wrote it as standalone application, it displays correctly.
Explain what is the problem here.
- 9
- 2d String in a BoxHi,
I want to draw a string of varying size inside a box.
g.drawString("........string....", x, y)
g.drawBox(x, y, w, h);
-------
|String| h
-------
w
Is there a good way to calculate the size of the box?
- 10
- Switch on StringsHello, I have code that looks like this:
switch(myColor){
case "blue":
{
this.setForeground(Color.blue);
break;
}
case "red":
{
this.setForeground(Color.red);
break;
}
case "green":
{
this.setForeground(Color.green);
break;
}
default:
{
this.setForeground(Color.blue);
}
}
myColor is a String being read in from an HTML file PARAM line.
The above code doesn't work, because switch doesn't work with strings.
So I was wondering how else I can do this...
ttyl
- 11
- Teaching Children (was Re: Help, where to start learning Java)"Roedy Green" <email***@***.com> wrote in
message news:email***@***.com...
> I was lead counselor at a computer summer camp. I interviewed all the
> kids and discovered most of them wanted more than anything to write
> their own video games. There were programming novices. But within a
> week nearly every kid had written a game or animation. I was utterly
> blown away how fast they learned. In the breaks they DEMANDED to learn
> trigonometry, which blew the mind of a math prof who was watching the
> production.
>
> The other thing was the kids wrote nothing but commented/structured
> code. They never saw anything else, so it never occurred to them to
> do other wise.
Now this I didn't realize.
I had no idea you had experience in teaching children? I have been
looking for ideas to teach and stimulate desire to learn logic and
mathmatics in younger children. It is my belief that subjects which are
typically reserved for higher education such as trig, calculus, discrete
math, deductive logic could all be started before children ever leave
elementary. The trick would only be to interest the children, and present
the material in a way that it could be absorbed.
Can you offer any insight into this matter? Into teaching children how to
make games? What engine did you use (I suppose you were using Java).
--
LTP
:)
- 12
- Getting images in appletI have an applet that reads jpg's. It works in AppletViewer but I get a
permission block for reading the file when I load it in my browser (all the
files in this case are local). How would I get permissions for it it to run
in a browser, and what would I need to do if I were to upload this to a
website?
- 13
- Open File componentThe usual file open component on a form consists of a label describing
the file, a text field that accepts a file name and a command button
that brings up a file chooser.
Is there a "standard" component that does this preferably a bean that
can be added to NetBeans?
- 14
- Eclipse + Tomcat plugin: problem with automatic class reloadingHi all,
I am having a problem using the DevLoader that comes with the eclipse
plugin for Tomcat from sysdeo.
It is loading classes okay from locations.
But it is not reloading them when they change.
The reloading works okay for a class that is WEB-INF/classes.
Here are the details:
Versions:
eclipse version 2.1.1
eclipse Tomcat plugin V 2.2.1
Tomcat version 4.1.29
JDK 1.3.1_04
I have extracted the DevLoader zip into [Tomcat Home]/server/classes
directory.
The tomcat server is using this DevLoader to load the classes.
I set the debug level in my web-app Context in conf/server.xml for the
loader to 4.
(<Loader className="org.apache.catalina.loader.DevLoader"
reloadable="true" debug="4"/> )
Logging is redirected to the console.
I can see output in the console that shows that it added my classes
location:
[DevLoader] added file:/C:/dev/workspace/Test/classes/
This is the location to find a class ims.test.TestServlet.
And it is able to find this class:
WebappClassLoader: loadClass(ims.test.TestServlet, false)
WebappClassLoader: Searching local repositories
WebappClassLoader: findClass(ims.test.TestServlet)
WebappClassLoader: findClassInternal(ims.test.TestServlet)
WebappClassLoader: loadClass(javax.servlet.http.HttpServlet, false)
WebappClassLoader: Delegating to parent classloader
WebappClassLoader: Loading class from parent
WebappClassLoader: Returning class class ims.test.TestServlet
WebappClassLoader: Loaded by WebappClassLoader
available:
delegate: false
repositories:
/WEB-INF/classes/
required:
I find it strange that my location
(file:/C:/dev/workspace/Test/classes/) is under the repositories.
If change the code (recompile) ims.test.TestServlet it is NOT
reloaded.
However, if I have a class that is to be found in WEB-INF/classes
e.g. I have a different class ims.TestServlet that is in
WEB-INF/classes/
WebappClassLoader: loadClass(ims.TestServlet, false)
WebappClassLoader: Searching local repositories
WebappClassLoader: findClass(ims.TestServlet)
WebappClassLoader: findClassInternal(ims.TestServlet)
WebappClassLoader: Returning class class ims.TestServlet
WebappClassLoader: Loaded by WebappClassLoader
available:
delegate: false
repositories:
/WEB-INF/classes/
required:
Then if I change ims.TestServlet it IS reloaded.
WebappClassLoader: Resource '/WEB-INF/classes/ims/TestServlet.class'
was modified; Date is now: Tue Dec 23 10:33:32 GMT 2003 Was: Tue Dec
23 09:28:57 GMT 2003
thank you for any help you can give,
and best wishes for Christmas + the New Year,
Grainne Coghlan
- 15
- Mail APIi wrote program for sending mail from one server to another but while
comile time it shows an error like Mail API is not found.. i was
downloaded it from sun..but i dont know where to install this API..so,
can u please tell me...?
|
|
|