comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * Java 1.5 Enums - 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8cd26ba0bb283203 * problem deploying jsps with tomcat - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/99818e82b7db6bcc * how to click a button, a node in a tree is selected - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a4f4d252717cfbd6 * Invalid Trademark Character Saved in Oracle - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b03bcf2882945102 * Help needed! how to deploy java application - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1be98d1355247063 * Tomcat - DataSource Exception - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7adac2daa2a6844f * Java Question - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bf3236c98b871078 * J2ME Question re System.out and System.err - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ea1ce20302b8c658 * How to tell if a drive is local or remote in Java ???? - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/373f029a6fac31a9 * Question about passing values? - 2 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8fe1c15e0fc2a949 * Version 1.3.1 Versus 1.4.2_04 - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/65e179ef76a09f65 * Creating primitive data types from contents of String - 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4d8fc307a0b9125d * Using resMgr to automate data processing - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/74f2576a00ff8e33 * RMI - Trying a simple example - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9d7781a5ac772a98 * NativeJ Ver 4.5.0 - Java EXE Maker - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c673790089cda49e * background image help - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b0ae1fde552f3595 * Difference between JavaServerFaces and JavaServerPages+Swing ? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8aece321c50238bc ========================================================================== TOPIC: Java 1.5 Enums http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8cd26ba0bb283203 ========================================================================== == 1 of 4 == Date: Sat, Nov 13 2004 12:12 pm From: Chas Douglass <[EMAIL PROTECTED]> I'm interested in using the new Java 1.5 Enum type, but I'm wondering if it's the best way to represent certain values retrofitting into a current application. The problem I'm having is understanding how to create enums "on the fly". That is, the underlying value is already stored in a database as an integer. I'd like to retrieve that integer value and "reconstruct" an appropriate enum. Perhaps I'm missing something obvious (it wouldn't be the first time) but the design of the enum type seems resistant to this simple application, and probably for good reason. I don't beleive it's reasonable to store a serialized version of the enum -- that would break SQL queries on the database. So is there a reasonable way to implement this, or should I stick with "static final int" constants. Thanks. Chas Douglass == 2 of 4 == Date: Sat, Nov 13 2004 12:48 pm From: "Jj" <[EMAIL PROTECTED]> The reason that you want to use Enum type is that you can refer to some "types" by names. That means you already know that you are dealing with, not to generate then dynamically on the fly. If that's indeed what you want to do,that means your data are static, then you will not want to store those data in the database (either from a configuation/resource file). I don't see any reason why you want to do this :-) "Chas Douglass" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm interested in using the new Java 1.5 Enum type, but I'm wondering if > it's the best way to represent certain values retrofitting into a current > application. > > The problem I'm having is understanding how to create enums "on the fly". > That is, the underlying value is already stored in a database as an > integer. > > I'd like to retrieve that integer value and "reconstruct" an appropriate > enum. > > Perhaps I'm missing something obvious (it wouldn't be the first time) but > the design of the enum type seems resistant to this simple application, and > probably for good reason. > > I don't beleive it's reasonable to store a serialized version of the enum > -- that would break SQL queries on the database. > > So is there a reasonable way to implement this, or should I stick with > "static final int" constants. > > Thanks. > > Chas Douglass == 3 of 4 == Date: Sat, Nov 13 2004 2:59 pm From: "Tony Morris" <[EMAIL PROTECTED]> "Chas Douglass" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm interested in using the new Java 1.5 Enum type, but I'm wondering if > it's the best way to represent certain values retrofitting into a current > application. > > The problem I'm having is understanding how to create enums "on the fly". > That is, the underlying value is already stored in a database as an > integer. > > I'd like to retrieve that integer value and "reconstruct" an appropriate > enum. > > Perhaps I'm missing something obvious (it wouldn't be the first time) but > the design of the enum type seems resistant to this simple application, and > probably for good reason. > > I don't beleive it's reasonable to store a serialized version of the enum > -- that would break SQL queries on the database. > > So is there a reasonable way to implement this, or should I stick with > "static final int" constants. > > Thanks. > > Chas Douglass You want to create an enum and a reverse mapping. Suppose you have 2 ints {0,1} that mean something {BLACK, WHITE}. public enum X { BLACK(0), WHITE(1); private static java.util.Map<Integer, X> m; private int i; X(int i) { if(X.m == null) { X.m = new java.util.HashMap<Integer, X>(); } X.m.put(i, this); this.i = i; } public int getI() { return i; } public static X fromInt(int i) { return m.get(i); } } -- Tony Morris http://xdweb.net/~dibblego/ == 4 of 4 == Date: Sat, Nov 13 2004 2:13 pm From: Oscar kind <[EMAIL PROTECTED]> Chas Douglass <[EMAIL PROTECTED]> wrote: > I'm interested in using the new Java 1.5 Enum type, but I'm wondering if > it's the best way to represent certain values retrofitting into a current > application. > > The problem I'm having is understanding how to create enums "on the fly". > That is, the underlying value is already stored in a database as an > integer. [...] > So is there a reasonable way to implement this, or should I stick with > "static final int" constants. The latter, but preferably using Integer objects (you can compare them directly with values from the DB). If the enumerated values come from the database, they're probably stored in an unchanging table. Or at least they should be: that way data integrity for the enumeration is handled by the database, as for everything else. Also, you can use an extra column with a description or whatever. Now if possible, you just use some general characteristic (i.e. some flag set or not) of the rows in that table. But in most real-life situations this is too convoluted, and you end up using constants refering to the primary keys. Enums in this regards are nice, but it's just as easy to use immutable objects. It's even easier to use the database to get a list of all values, because you can use the same code as for all other lists. And as an added bonus it even works when you're using 1.4. -- Oscar Kind http://home.hccnet.nl/okind/ Software Developer for contact information, see website PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2 ========================================================================== TOPIC: problem deploying jsps with tomcat http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/99818e82b7db6bcc ========================================================================== == 1 of 1 == Date: Sat, Nov 13 2004 1:00 pm From: "Jj" <[EMAIL PROTECTED]> looks like the compiled class file is not in the right classpath. please make sure that you have the TableBean2.class somewhere in the classpath as "cal/TableBean2.class". Or you can put the class in a jar file and put the jar file in the class path. "Ryan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The only java beans I can get to work are the ones that come in the example > directory. > > I made a simple jsp and put it in the 'cal' package under the examples > directory. It works fine if use the TableBean that comes with tomcat as > follows: > > <jsp:useBean id="table" scope="session" class="cal.TableBean" /> > > If I save TableBean as TableBean2.java and I only change the class name and > the constructor to TableBean2 and recompile, I then use the following to > call it in my jsp > > <jsp:useBean id="table" scope="session" class="cal.TableBean2" /> > > I get the following set of errors: I get these errors everywhere I use a > bean I create. I do not get errors when I use the default beans. Is there a > configuration parameter i need to set? I don't see it in any books. > > org.apache.jasper.JasperException: Unable to compile class for JSP > > An error occurred at line: 13 in the jsp file: /jsp/cal/hw6.jsp > > Generated servlet error: > [javac] Compiling 1 source file > > C:\Tomcat_new\work\Standalone\localhost\examples\jsp\cal\hw6_jsp.java:63: > cannot resolve symbol > symbol : class TableBean2 > location: package cal > cal.TableBean2 table = null; > ^ > > > > An error occurred at line: 13 in the jsp file: /jsp/cal/hw6.jsp > > Generated servlet error: > C:\Tomcat_new\work\Standalone\localhost\examples\jsp\cal\hw6_jsp.java:65: > cannot resolve symbol > symbol : class TableBean2 > location: package cal > table = (cal.TableBean2) pageContext.getAttribute("table", > PageContext.SESSION_SCOPE); > ^ > > > > An error occurred at line: 13 in the jsp file: /jsp/cal/hw6.jsp > > Generated servlet error: > C:\Tomcat_new\work\Standalone\localhost\examples\jsp\cal\hw6_jsp.java:68: > cannot resolve symbol > symbol : class TableBean2 > location: package cal > table = (cal.TableBean2) > java.beans.Beans.instantiate(this.getClass().getClassLoader(), > "cal.TableBean2"); > ^ > 3 errors > > ========================================================================== TOPIC: how to click a button, a node in a tree is selected http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a4f4d252717cfbd6 ========================================================================== == 1 of 1 == Date: Sat, Nov 13 2004 1:40 pm From: "HS1" <[EMAIL PROTECTED]> Hello all I have a MenuTreeNavigator in a MainWindow that allows users to select different nodes as the following: ---------------------------------------------------------------------------- ---------------------------- public class MenuTreeNavigator implements TreeSelectionListener, TreeExpansionListener { ..... public MenuTreeNavigator(MainWindow mainWindow) { this.mainWindow = mainWindow; ........ public void valueChanged(TreeSelectionEvent treeSelectionEvent) { Object selectedNode = treeSelectionEvent.getPath().getLastPathComponent(); if (selectedNode.getClass().getName().equals("MainClientNode")) { //MainClientNode is a class MainClientNode that implements MutableTreeNode MainClientNode clientNode = (MainClientNode) selectedNode; mainWindow.setRightPane(.........); } if (selectedNode.getClass().getName().equals("ClientNode")) { .... } ---------------------------------------------------------------------------- When user click s(or select) a MainClientNode, the MainWindow will set a object for RightPane. What I want now is that I have a button in the MainWindow, when I click this button, that MainClienNode is also selected (as I have only one MainClientNode) Is it possible to do that? Please help Many thanks S.H1 ========================================================================== TOPIC: Invalid Trademark Character Saved in Oracle http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b03bcf2882945102 ========================================================================== == 1 of 1 == Date: Sat, Nov 13 2004 2:17 pm From: Matt Parker <[EMAIL PROTECTED]> Neel Gutierrez wrote: > And because of this when you view > text that has these symbols using a reporting tool such as Actuate, > the invalid character is displayed instead. There is no problem > displaying these characters back to the userÂ…that is, if/when the > application reads it from the database and displays it to the user > thru JSP pages. Has anyone come across this problem before? Any > suggestions and/or recommendations as how to fix it? So far I've tried > the line of code: request.setcharacterencoding("utf-8)...still does > not fix the problem. Appreciate any help. I've had to do this before... Basically, Word has "special" characters that don't necessarily map to standard language encodings. The way we did it was to have a lookup and store the HTML equivalent (for want of a better standard) in the database. You can thank Microsoft for this one. Matt ========================================================================== TOPIC: Help needed! how to deploy java application http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1be98d1355247063 ========================================================================== == 1 of 1 == Date: Sat, Nov 13 2004 2:21 pm From: Michael Borgwardt <[EMAIL PROTECTED]> Andrew Thompson wrote: > That might work fine on one OS, using one particular version > of Java, and one particular language and one particular set of installed fonts. ========================================================================== TOPIC: Tomcat - DataSource Exception http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7adac2daa2a6844f ========================================================================== == 1 of 1 == Date: Sat, Nov 13 2004 2:37 pm From: "Rhino" <[EMAIL PROTECTED]> I don't know the answer to your question Martin but you may have more luck asking Tomcat questions on the tomcat-user mailing list. Here is the URL for the archive: http://www.mail-archive.com/[email protected]/ This is a very active mailing list with many very experienced people. You can subscribe to this mailing list at http://jakarta.apache.org/site/mail2.html. Rhino "Martin Huber" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > > i have a problem. I am using Tomcat 4.0 and MySql as database. I want > using the database connection pooling mechanism in Tomcat, but I have > problems. > > If I test the connection, I get following error message: > > TyrexDataSourceFactory: Cannot create DataSource, Exception > java.lang.NoClassDefFoundError: tyrex/jdbc/xa/EnabledDataSource > at org.apache.naming.factory.TyrexDataSourceFactory.getObjectInstance(Ty > rexDataSourceFactory.java:163) > at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory. java:165) > at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:301) > . > . > . > A problem occurred while retrieving a DataSource object > javax.naming.NamingException: Exception creating DataSource: > tyrex/jdbc/xa/EnabledDataSource > > > So, I have searched in different groups, but I did not found any > solution for my problem. I have enclosed my sourcecode. Maybe someone > can help me. > > Thank you very much > > Martin Huber > > P.S. Sorry for my english... > > > Code in DatabaseManager.java (Servlet): > try { > Context initCtx = new InitialContext(); > Context envCtx = (Context) initCtx.lookup("java:comp/env"); > ds = (DataSource) envCtx.lookup("jdbc/DatabaseManager"); > con = ds.getConnection(); > Statement stmt = con.createStatement(); > System.out.println("executed lookup for jdbx. JON"); > } > catch (javax.naming.NamingException e){ > System.out.println("A problem occurred while retrieving a DataSource > object"); > System.out.println(e.toString()); > } > > > > Settings in server.xml: > > <Context path="/DatabaseManager" > docBase="DatabaseManager" > debug="1" > reloadable="true" > crossContext="false"> > > <Resource name="jdbc/DatabaseManager" > auth="SERVLET" > type="javax.sql.DataSource" /> > > <ResourceParams name="jdbc/DatabaseManager"> > > > <parameter> > <name>factory</name> > <value>org.apache.commons.dbcp.BasicDataSourceFactory</value> > </parameter> > > <parameter> > <name>driverClassName</name> > <value>org.gjt.mm.mysql.Driver</value> > </parameter> > > <parameter> > <name>url</name> > <value>jdbc:mysql:///bfdr</value> > </parameter> > > <parameter> > <name>username</name> > <value></value> > </parameter> > > <parameter> > <name>password</name> > <value></value> > </parameter> > > <parameter> > <name>maxActive</name> > <value>20</value> > </parameter> > > <parameter> > <name>maxIdle</name> > <value>10</value> > </parameter> > > <parameter> > <name>maxWait</name> > <value>-1</value> > </parameter> > > <parameter> > <name>testOnBorrow</name> > <value>true</value> > </parameter> > > <parameter> > <name>testOnIdle</name> > <value>true</value> > </parameter> > > <parameter> > <name>validationQuery</name> > <value>select current_date</value> > </parameter> > > </ResourceParams> > </Context> > > > > > Settings in web.xml: > > <resource-ref> > <description> > BFD-Regensburg > </description> > <res-ref-name> > jdbc/DatabaseManager > </res-ref-name> > <res-type> > javax.sql.DataSource > </res-type> > <res-auth> > SERVLET > </res-auth> > </resource-ref> ========================================================================== TOPIC: Java Question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bf3236c98b871078 ========================================================================== == 1 of 1 == Date: Sat, Nov 13 2004 3:01 pm From: "Tony Morris" <[EMAIL PROTECTED]> "scorpion53061" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > My company has asked me to learn Java. My background is vb.net. > > They bought me Sun Java Studio Enterprise 6 2004Q1 > > Please recommend a comprehensive book I can sit down and go hide for about 6 > months and get me going. > > By the way, .NET had ADO.NET? Is there naything similar in java? > .NET is analogous to 'Java'. ADO.NET is analogous to JDBC 3.0. This list goes on... -- Tony Morris http://xdweb.net/~dibblego/ ========================================================================== TOPIC: J2ME Question re System.out and System.err http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ea1ce20302b8c658 ========================================================================== == 1 of 1 == Date: Sat, Nov 13 2004 3:00 pm From: "Rhino" <[EMAIL PROTECTED]> I am writing my first J2ME applications using EclipseME and/or Sun Wireless Toolkit 2.2. When I write System.out.println() or System.err.println() statements, I know that this output is sent to the console when I am running my applications on the the emulators. Where does it go when I am running my application on the PDA? Ideally, I'd like to be able to see it but I'll be content if you tell me that I can't see it; I know that I should be debugging on the emulators, not on the PDA itself ;-) However, I would like some assurances that the console output isn't getting written to some kind of file on the PDA that will eventually exhaust my storage space. By the way, what is the best way of logging on a PDA? I don't see any logging stuff in the MIDP1.0 API so I'm not sure what approach people are using for logging important information for the user or tech support people. -- Rhino --- rhino1 AT sympatico DOT ca "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies." - C.A.R. Hoare ========================================================================== TOPIC: How to tell if a drive is local or remote in Java ???? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/373f029a6fac31a9 ========================================================================== == 1 of 3 == Date: Sat, Nov 13 2004 3:37 pm From: "Gil Blais" <[EMAIL PROTECTED]> Does anyone know how to do this? Would surely help me right now... Thanks in advance, Gil Blais == 2 of 3 == Date: Sun, Nov 14 2004 12:21 am From: "Boudewijn Dijkstra" <[EMAIL PROTECTED]> "Gil Blais" <[EMAIL PROTECTED]> schreef in bericht news:[EMAIL PROTECTED] > Does anyone know how to do this? Would surely help me right now... Runtime.exec(new String[] {"C:\Windows\System32\net.exe", "use"}); == 3 of 3 == Date: Sun, Nov 14 2004 12:41 am From: Oscar kind <[EMAIL PROTECTED]> Gil Blais <[EMAIL PROTECTED]> wrote: > Does anyone know how to do this? Would surely help me right now... The subject I see in my newsreader is: "How to tell if a drive is local or r" So please restate your question in the body of your post. Also, the part I do see raises one important question: what is a "drive"? If by chance you mean a "disk drive", as Windows denotes by a letter, then no: this is not possible, because it is OS specific. Compare to Linux: - the entire filesystem is one tree (instead of up to 26 with Windows) - any directory can be mounted from several sources, such as another harddisk, a floppy disk, CD-ROM drive, NFS share, Windows share, etc. In any case (at least using either Windows or Linux), the OS takes care of all those details and you don't know if a file location is remote or not. In a Java program, I find it best to use this distinction: - If it is represented as a File, it is local. - If it is represented as a URL, it can be remote; so treat it as such. -- Oscar Kind http://home.hccnet.nl/okind/ Software Developer for contact information, see website PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2 ========================================================================== TOPIC: Question about passing values? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8fe1c15e0fc2a949 ========================================================================== == 1 of 2 == Date: Sat, Nov 13 2004 3:55 pm From: "Mike" <[EMAIL PROTECTED]> Actualy, there is an intersting way to do this (assuming that the method is in the same class as the object, and the object is global), you could make the variable an Integer, and reference if the object==tester, this tests the memory location, and since all you are doing is passing a pointer to the object, it will return true if the object passed is the same as the tester, in which case you would print out the specific name taht you choose... public class VariableTester { static Integer theOne, theTwo, theThree; public static void main(String[] args) { theOne = new Integer(1); theTwo = new Integer(2); theThree = new Integer(3); test(theTwo); test(theOne); test(theThree); } public static void test(Integer test) { if(test==theOne) System.out.println("theOne"); else if(test==theTwo) System.out.println("theTwo"); else if(test==theThree) System.out.println("theThree"); } } That code does the trick (at least it works)... Honestly, I have to agree with the other people, I cant really see a reason for doing this because you have to know what you named them, and then print out the specific String depding on which memory location is equal. Oh well, I liked the challange of figuring this out, hope it helps. == 2 of 2 == Date: Sat, Nov 13 2004 3:59 pm From: "Mike" <[EMAIL PROTECTED]> Sorry, I read the question wrong, although my previous post does work, you might want to do something more like this for the method: public static void test(int test) { if(theOne.intValue()==test) System.out.println("theOne); } This will also create the same output. ========================================================================== TOPIC: Version 1.3.1 Versus 1.4.2_04 http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/65e179ef76a09f65 ========================================================================== == 1 of 3 == Date: Sat, Nov 13 2004 4:19 pm From: [EMAIL PROTECTED] (Kevin Simonson) Is there something about the differences between Java versions 1.3.1 and 1.4.2_04 that keeps me from declaring an object of one class when I just got done compiling that class' definition? Take a look at my code below. On host "nail", that has version 1.4.2_04 installed, I can write class "Bug" and compile it, and when I compile class "BugDriver" that declares an object of type "Bug" and uses it, it compiles fine and runs fine. On host "star", that has version 1.3.1 installed, I compile the same "Bug" class, but when I try to compile the same "BugDriver" class I get an error message and the code doesn't compile. Does anybody know why this is happening? I wouldn't think there would be that much differences between two versions of Java. ---Kevin Simonson "You'll never get to heaven, or even to LA, if you don't believe there's a way." from _Why Not_ ,------------------------------------------------------------------------------ |nail:Ncl/Java_bash-2.05b$ hostname |nail.cs.byu.edu |nail:Ncl/Java_bash-2.05b$ java -version |java version "1.4.2_04" |Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) |Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode) |nail:Ncl/Java_bash-2.05b$ cat Bug.java |public class Bug |{ | int bug; | | public Bug ( int bg) | { | bug = bg; | } | | public int bugSquared () | { | return bug * bug; | } |} |nail:Ncl/Java_bash-2.05b$ cat BugDriver.java |public class BugDriver |{ | public static void main ( String[] arguments) | { | System.out.println | ( "(new Bug( 7)).bugSquared() == " + (new Bug( 7)).bugSquared() + '.'); | } |} |nail:Ncl/Java_bash-2.05b$ javac Bug.java |nail:Ncl/Java_bash-2.05b$ javac BugDriver.java |nail:Ncl/Java_bash-2.05b$ java BugDriver |(new Bug( 7)).bugSquared() == 49. |nail:Ncl/Java_bash-2.05b$ `------------------------------------------------------------------------------ ,------------------------------------------------------------------------------ |[EMAIL PROTECTED] Rid3]$ hostname |star |[EMAIL PROTECTED] Rid3]$ java -version |java version "1.3.1" |jdkgcj 0.2.3 (http://www.arklinux.org/projects/jdkgcj) |gcj (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5) |Copyright (C) 2002 Free Software Foundation, Inc. |This is free software; see the source for copying conditions. There is NO |warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |[EMAIL PROTECTED] Rid3]$ cat Bug.java |public class Bug |{ | int bug; | | public Bug ( int bg) | { | bug = bg; | } | | public int bugSquared () | { | return bug * bug; | } |} |[EMAIL PROTECTED] Rid3]$ cat BugDriver.java |public class BugDriver |{ | public static void main ( String[] arguments) | { | System.out.println | ( "(new Bug( 7)).bugSquared() == " + (new Bug( 7)).bugSquared() + '.'); | } |} |[EMAIL PROTECTED] Rid3]$ javac Bug.java |[EMAIL PROTECTED] Rid3]$ javac BugDriver.java |BugDriver.java: In class `BugDriver': |BugDriver.java: In method `BugDriver.main(java.lang.String[])': |BugDriver.java:6: Class `Bug' not found in type declaration. | ( "(new Bug( 7)).bugSquared() == " + (new Bug( 7)).bugSquared() + '.'); | ^ |1 error |[EMAIL PROTECTED] Rid3]$ `------------------------------------------------------------------------------ == 2 of 3 == Date: Sat, Nov 13 2004 5:29 pm From: "Jj" <[EMAIL PROTECTED]> do you have "." - the current directory in the class path ? try to add "." in the classpath when you compile the second class. good luck. "Kevin Simonson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is there something about the differences between Java versions 1.3.1 > and 1.4.2_04 that keeps me from declaring an object of one class when > I just got done compiling that class' definition? > > Take a look at my code below. On host "nail", that has version > 1.4.2_04 installed, I can write class "Bug" and compile it, and when I > compile class "BugDriver" that declares an object of type "Bug" and > uses it, it compiles fine and runs fine. > > On host "star", that has version 1.3.1 installed, I compile the > same "Bug" class, but when I try to compile the same "BugDriver" class > I get an error message and the code doesn't compile. > > Does anybody know why this is happening? I wouldn't think there > would be that much differences between two versions of Java. > > ---Kevin Simonson > > "You'll never get to heaven, or even to LA, > if you don't believe there's a way." > from _Why Not_ > > ,--------------------------------------------------------------------------- --- > |nail:Ncl/Java_bash-2.05b$ hostname > |nail.cs.byu.edu > |nail:Ncl/Java_bash-2.05b$ java -version > |java version "1.4.2_04" > |Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) > |Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode) > |nail:Ncl/Java_bash-2.05b$ cat Bug.java > |public class Bug > |{ > | int bug; > | > | public Bug ( int bg) > | { > | bug = bg; > | } > | > | public int bugSquared () > | { > | return bug * bug; > | } > |} > |nail:Ncl/Java_bash-2.05b$ cat BugDriver.java > |public class BugDriver > |{ > | public static void main ( String[] arguments) > | { > | System.out.println > | ( "(new Bug( 7)).bugSquared() == " + (new Bug( 7)).bugSquared() + '.'); > | } > |} > |nail:Ncl/Java_bash-2.05b$ javac Bug.java > |nail:Ncl/Java_bash-2.05b$ javac BugDriver.java > |nail:Ncl/Java_bash-2.05b$ java BugDriver > |(new Bug( 7)).bugSquared() == 49. > |nail:Ncl/Java_bash-2.05b$ > `--------------------------------------------------------------------------- --- > ,--------------------------------------------------------------------------- --- > |[EMAIL PROTECTED] Rid3]$ hostname > |star > |[EMAIL PROTECTED] Rid3]$ java -version > |java version "1.3.1" > |jdkgcj 0.2.3 (http://www.arklinux.org/projects/jdkgcj) > |gcj (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5) > |Copyright (C) 2002 Free Software Foundation, Inc. > |This is free software; see the source for copying conditions. There is NO > |warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > | > |[EMAIL PROTECTED] Rid3]$ cat Bug.java > |public class Bug > |{ > | int bug; > | > | public Bug ( int bg) > | { > | bug = bg; > | } > | > | public int bugSquared () > | { > | return bug * bug; > | } > |} > |[EMAIL PROTECTED] Rid3]$ cat BugDriver.java > |public class BugDriver > |{ > | public static void main ( String[] arguments) > | { > | System.out.println > | ( "(new Bug( 7)).bugSquared() == " + (new Bug( 7)).bugSquared() + '.'); > | } > |} > |[EMAIL PROTECTED] Rid3]$ javac Bug.java > |[EMAIL PROTECTED] Rid3]$ javac BugDriver.java > |BugDriver.java: In class `BugDriver': > |BugDriver.java: In method `BugDriver.main(java.lang.String[])': > |BugDriver.java:6: Class `Bug' not found in type declaration. > | ( "(new Bug( 7)).bugSquared() == " + (new Bug( 7)).bugSquared() + '.'); > | ^ > |1 error > |[EMAIL PROTECTED] Rid3]$ > `--------------------------------------------------------------------------- --- == 3 of 3 == Date: Sat, Nov 13 2004 9:21 pm From: "Thomas G. Marshall" <[EMAIL PROTECTED]> Kevin Simonson coughed up: > Is there something about the differences between Java versions 1.3.1 > and 1.4.2_04 that keeps me from declaring an object of one class when > I just got done compiling that class' definition? > > Take a look at my code below. [...] You've tried to enclose your examples in a kind of ascii art box. This places a "|" in front of every line. Bad idea. 1. That character gets misinterpreted as a reply indent character (or whatever they're /supposed/ to be called). 2. It makes it hard to cut and paste out your examples so that I or anyone else can easily see if they compile and run ok on our systems. ...[thwack]... -- Onedoctortoanother:"Ifthisismyrectalthermometer,wherethehell'smypen???" ========================================================================== TOPIC: Creating primitive data types from contents of String http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4d8fc307a0b9125d ========================================================================== == 1 of 4 == Date: Sat, Nov 13 2004 5:28 pm From: [EMAIL PROTECTED] (Jesper Sahner) Hi again! Consider the following problem: You have some information stored in a data-file, and in addition you have a header-file with a description of the record-layout (variable-name, position, length, format, label etc.). The task then is to read from the data-file using the header-information. If e.g. the header contains a description of a variable 'var1' of type 'double' and another variable 'var2' of type 'int' then the Java-code should declare these variables on basis of the header-information like: double var1; int var2; Then you could make some calculations involving var1 and var2, write the result to a new file etc. - very similar to a database-lookup. How would you do this? Regards, Jesper == 2 of 4 == Date: Sat, Nov 13 2004 9:30 pm From: Sudsy <[EMAIL PROTECTED]> Jesper Sahner wrote: <snip> > The task then is to read from the data-file using the > header-information. If e.g. the header contains a description of a > variable 'var1' of type 'double' and another variable 'var2' of type > 'int' then the Java-code should declare these variables on basis of > the header-information like: > double var1; > int var2; > > Then you could make some calculations involving var1 and var2, write > the result to a new file etc. - very similar to a database-lookup. Again, your motive escapes me (and others, apparently). A variable is merely a convenient handle to either a primitive or an Object. The value or object being referenced has no need to know the name(s) (if any) which refer to it. BTW, I just LOVED the post which mentioned the scenario of foo( 3 )! Guess what? There's no variable name associated with the value! Please think carefully about what you're trying to achieve. It might turn out to be impossible, and for good reason. Perhaps if you describe what you're trying to accomplish? ... -- Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development. == 3 of 4 == Date: Sun, Nov 14 2004 12:14 am From: Casey Hawthorne <[EMAIL PROTECTED]> Does the following page describe what you are trying to do? http://mindprod.com/jgloss/eval.html eval In many languages you can take a dynamically created String such as "6*(4+6^2)-cos(20)" and ask to have it evaluated, as if it were a miniature computer program. The function to do this often has a name such as eval. Java has no such function. What can you do? Here are four different approaches: ... -- Regards, Casey == 4 of 4 == Date: Sun, Nov 14 2004 1:08 am From: [EMAIL PROTECTED] (hiwa) [EMAIL PROTECTED] (Jesper Sahner) wrote in message news:<[EMAIL PROTECTED]>... I would write a simple text processing program which generate a relevant part -- variable declaration part -- of the target Java source code. As mentioned earlier, names in the source program are only relevant to compiler. In order to feed them to the compiler, we can not use nothing but ordinary source code. We have to make source text from your header etc. ========================================================================== TOPIC: Using resMgr to automate data processing http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/74f2576a00ff8e33 ========================================================================== == 1 of 1 == Date: Sat, Nov 13 2004 8:13 pm From: [EMAIL PROTECTED] (http://vmdd.tech.mylinuxisp.com/catalog/) Reading the resMgr description, I realized that words could not describe enough its ability to manage resources (literally and figuratively speaking). Not only that, no one would ever recognize its patently unique and powerful ability to automate data processing. I will be available to demo resMgr to a select few. Contact me at: http://vmdd.tech.mylinuxisp.com/catalog/ Binh ========================================================================== TOPIC: RMI - Trying a simple example http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9d7781a5ac772a98 ========================================================================== == 1 of 1 == Date: Sat, Nov 13 2004 9:24 pm From: [EMAIL PROTECTED] (Sheetal Khemani) Hi All, I am running a simple RMI example - to no avail. The example I'm trying out is at: http://java.sun.com/j2se/1.4.2/docs/guide/rmi/getstart.doc.html I've tried to follow it to the T, but there's probably something I'm missing ... I've got server code, that defines a class that extends UnicastRemoteObject and implements an interface (the interface extends Remote). Then I bind an instance of this class to a 'name'. I've got client code, that somehow gets a reference to the remote instance using that same 'name'. And then it invokes a method on that remote instance. It's magical. This is so not working. I can set up the server, and the object gets bound and everything. When I try the client, it gives the following error: /usr/local/apache2/htdocs/public_html #206 > appletviewer hello.html HelloApplet exception: access denied (java.net.SocketPermission 192.168.0.103:1099 connect,resolve) java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.0.103:1099 connect,resolve) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269) at java.security.AccessController.checkPermission(AccessController.java:401) at java.lang.SecurityManager.checkPermission(SecurityManager.java:524) at java.lang.SecurityManager.checkConnect(SecurityManager.java:1026) at java.net.Socket.connect(Socket.java:446) at java.net.Socket.connect(Socket.java:402) at java.net.Socket.<init>(Socket.java:309) at java.net.Socket.<init>(Socket.java:124) at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22) at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128) at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:562) at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185) at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171) at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:313) at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source) at java.rmi.Naming.lookup(Naming.java:84) at examples.hello.HelloApplet.init(HelloApplet.java:59) at sun.applet.AppletPanel.run(AppletPanel.java:353) at java.lang.Thread.run(Thread.java:534) This is strange because my policy file, says something like: grant { // Allow everything for now permission java.security.AllPermission; }; Any ideas ? Thanks Sheetal PS: Here is all my code: public interface Hello extends Remote { String sayHello() throws RemoteException; } public class HelloImpl extends UnicastRemoteObject implements Hello { public HelloImpl() throws RemoteException { super(); } public String sayHello() { return "Hello World!"; } public static void main(String args[]) { // Create and install a security manager if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } try { HelloImpl obj = new HelloImpl(); // Bind this object instance to the name "HelloServer" Naming.rebind("//192.168.0.103/HelloServer", obj); System.out.println("HelloServer bound in registry"); } catch (Exception e) { System.out.println("HelloImpl err: " + e.getMessage()); e.printStackTrace(); } } } public class HelloApplet extends Applet { String message = "init"; // "obj" is the identifier that we'll use to refer // to the remote object that implements the "Hello" // interface Hello obj = null; public void init() { try { repaint(); //obj = (Hello)Naming.lookup("//" + getCodeBase().getHost() + "/HelloServer"); obj = (Hello)Naming.lookup("//192.168.0.103/HelloServer"); message = obj.sayHello(); repaint(); } catch (Exception e) { System.out.println("HelloApplet exception: " + e.getMessage()); e.printStackTrace(); } } public void paint(Graphics g) { g.drawString(message, 25, 50); } } ========================================================================== TOPIC: NativeJ Ver 4.5.0 - Java EXE Maker http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c673790089cda49e ========================================================================== == 1 of 1 == Date: Sat, Nov 13 2004 11:46 pm From: [EMAIL PROTECTED] (DobySoft) DobySoft is pleased to announce the release of NativeJ Ver 4.5.0! NativeJ automatically generates Win32 native EXE for your Java applications. No more ugly batch files! The executable generated by NativeJ looks and behaves like native Window applications. They can even be installed as services! There is no need to write custom JNI code or wrestle with a C compiler. Just click-and-go! It's that easy! New in this release: - Support for JDK/JRE V5.0 (JVM V1.5). - Redirection of stdout/stderr to popup message box (for GUI applications) or event log (for Win32 services). - Option to always delete embedded JAR files when EXE terminates. - Option to allow Win32 services to interact with desktop. For more information, please visit: http://www.dobysoft.com/products/nativej/index.html ========================================================================== TOPIC: background image help http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b0ae1fde552f3595 ========================================================================== == 1 of 1 == Date: Sun, Nov 14 2004 12:32 am From: "Ann" <[EMAIL PROTECTED]> I have a tree and the background color is set as follows: newContentPane.setOpaque(true); //content panes must be opaque newContentPane.setBackground(new Color(1.0f, 0.6f, 0.6f)); I would like to use a gif file instead of a solid color as a background image. How to? Or where to look please. ========================================================================== TOPIC: Difference between JavaServerFaces and JavaServerPages+Swing ? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8aece321c50238bc ========================================================================== == 1 of 1 == Date: Sun, Nov 14 2004 1:05 am From: [EMAIL PROTECTED] (Arnold Peters) Ok, I read a couple of intros for JavaServerFaces. But I could not figure out: What is the real difference between JavaServerFaces and the good ol' JavaServerPages+Swing Programming ? What can I do with JSF what I cannot with either JSP or Swing components ? Arni ======================================================================= You received this message because you are subscribed to the Google Groups "comp.lang.java.programmer". comp.lang.java.programmer [EMAIL PROTECTED] Change your subscription type & other preferences: * click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe Report abuse: * send email explaining the problem to [EMAIL PROTECTED] Unsubscribe: * click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe ======================================================================= Google Groups: http://groups-beta.google.com
