comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* [OT] Using hobby source code in your job ? - 4 messages, 4 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a60dfe865a7807c4
* why does this program not end? - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9d6aab266b4c0a16
* Data Structures for Stateful Inspection - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/425c393c88a4243e
* math.pow rounding problem - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3e00e118892196bb
* GAP and Java - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cf221d8987d4d5e5
* Java speed vs. C++. - 10 messages, 6 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e29354c898cb3523
* Parse Array of Objects - string delimiter java - 3 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6f00a610222e5584
* Javac error. - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/21513abc37c9cc4

==============================================================================
TOPIC: [OT] Using hobby source code in your job ?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a60dfe865a7807c4
==============================================================================

== 1 of 4 ==
Date: Sat, Dec 4 2004 4:28 pm
From: "E. Robert Tisdale"  

Andrew Koenig wrote:

> E. Robert Tisdale wrote:
> 
>>Who owns you?
> 
> No one.  Not any more.  That's part of the reason.

        http://careerlaunch.jpl.nasa.gov/



== 2 of 4 ==
Date: Sun, Dec 5 2004 1:02 am
From: "Ann"  


"E. Robert Tisdale" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Andrew Koenig wrote:
>
> > Unless you're being paid by the hour,
> > there is no such thing as "your own time".
>
> Spoken like a true company man.
> Who owns you?

Reminds me of the time the boss called us in for a chat
about "no overtime pay" and he says:
Those of you that are hourly, you are not allowed to work overtime.
Those of you that are staff, you are paid to get a job done.





== 3 of 4 ==
Date: Sat, Dec 4 2004 9:26 pm
From: "andthen"  

Nevermind, found the problem. There was one line that I took out before
posting the code that I didn't realize was creating a thread that keeps
running.





== 4 of 4 ==
Date: Sat, Dec 4 2004 11:17 pm
From: Scott Ellsworth  

In article <[EMAIL PROTECTED]>,
 "E. Robert Tisdale" <[EMAIL PROTECTED]> wrote:

> Your employer cannot compel you to transfer the copyright
> for code that you wrote on your own time
> or code that you wrote for another employer.

Slight correction: as I understand it (IANAL, but I did talk to one 
about this), most of us work under "work for hire" contracts.  Thus, 
everything we do on company time or with company materials is a work for 
hire, and implicitly copyrighted by them.  The "company materials" is 
the kicker - if you use one of their machines, or a compiler they paid 
for, or _any_ company materials to create your code, you could end up 
being judged as having done a work for hire.

In the case of the original poster, he did work prior to joining his 
prospective employeer.  Thus far, so good.

As soon as he uses it in a work project, or develops on it with their 
resources or on their time, it may have become a work for hire.  
Further, if it gets ugly, and you get hauled into court, then it really 
hurts if they have proof that you did things that might have turned it 
into a work for hire.

Remember, once it has become theirs, they potentially can go after 
others using the code for copyright violation, including you.  Most will 
not, but the recent SCO suits have shown that it _can_ happen.

There is a simple solution - most contracts I have signed as an employee 
have a section where I am to list products, patents, or software 
developed on my own where there might be a potential conflict.  Use 
those sections - describe in appropriately vague terms what you have 
done, and file for copyright.  (I know that you do not have to, but 
having done so will make it much easier if it ever does get to court.)

> My experience is that employers have no objection
> to using third party packages or even freeware
> if they can get the necessary licenses at a reasonable price.

This has been my experience as well.  Coughing up a few hundred for a 
third party product, even one which I wrote, is often not a problem, as 
long as they get the source, and the license is such that they get to 
keep that source and all modifications to it.

> Don't try to *sell* your employer a license
> as this creates a "conflict of interest".

I have had this work, but only when I was selling them a block of code 
already on the market, and where it was clear that they would own it 
once paying the price.  You are opening yourself up for questions, so I 
am not sure I would do this under most circumstances.

> You can distribute your code under an open source license
> and you should try to convince your employer
> to allow you to "contribute" to the package
> which would allow you to maintain your software on company time.

This has happened to me several times, and it has worked well.  Watch 
your license terms carefully, as they may get a bit excited if your 
library ends up GPLing their product.

Scott




==============================================================================
TOPIC: why does this program not end?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9d6aab266b4c0a16
==============================================================================

== 1 of 2 ==
Date: Sat, Dec 4 2004 8:45 pm
From: "andthen"  

I read the following in the Thread API:

When a Java Virtual Machine starts up, there is usually a single non-daemon
thread (which typically calls the method named main of some designated
class). The Java Virtual Machine continues to execute threads until either
of the following occurs:
- The exit method of class Runtime has been called and the security manager
has permitted the exit operation to take place.
- All threads that are not daemon threads have died, either by returning
from the call to the run method or by throwing an exception that propagates
beyond the run method.

In the program below I have two Threads, the first thread reaches the end of
main() and the second thread reaches the end of run() because I see all of
the print statements. But the program doesn't terminate (I have to kill it
with Control + c) and I'm wondering why that is.

public class Test {
    public static void main(String[] args) throws Exception {
        Test2 h = new Test2();
        System.out.println("before start");
        h.start();
        System.out.println("after start");
    }
}


public class Test2 extends Thread {
    public void run() {
    System.out.println("starting run");
    System.out.println("ending run");
    }
}







== 2 of 2 ==
Date: Sun, Dec 5 2004 12:17 am
From: Sudsy  

andthen wrote:
<snip>
> public class Test {
>     public static void main(String[] args) throws Exception {
>         Test2 h = new Test2();
>         System.out.println("before start");
>         h.start();
>         System.out.println("after start");
>     }
> }
> 
> 
> public class Test2 extends Thread {
>     public void run() {
>     System.out.println("starting run");
>     System.out.println("ending run");
>     }
> }

Works as expected for me, once you remove the public qualifier
from class Test2. Here's the output from 'java -version':

java version "1.4.2_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_02-b03)
Java HotSpot(TM) Client VM (build 1.4.2_02-b03, mixed mode)

Here's the output:

before start
after start
starting run
ending run

Command prompt immediately follows.

-- 
Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development.





==============================================================================
TOPIC: Data Structures for Stateful Inspection
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/425c393c88a4243e
==============================================================================

== 1 of 2 ==
Date: Sat, Dec 4 2004 6:34 pm
From: [EMAIL PROTECTED] (Yamin) 

"Captain Blammo" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL 
PROTECTED]>...
> I'm trying to write a basic stateful packet inspection application using
> JPcap in order to get a bit more familiar with TCP/IP, and was wondering if
> anyone could point me in the direction of the best/most common algorithms
> and data structures for delivering data to the right buffer based on source
> and destination IP and port for an incoming segment.
> 
> Thanks for any info!
> 
> CB

Check out ethereal (http://www.ethereal.com/).  It's pretty much
standard fare for protocol analyzing.

Yamin



== 2 of 2 ==
Date: Sun, Dec 5 2004 6:28 am
From: "Captain Blammo"  

> Forgive my ignorance, but this almost sounds like you might benefit from
> looking for NAT algorithms...

I've been poking around all over the place for all sorts of things, but
still no luck on the specific stuff I'm looking for.

I was thinking that I could stuff the source and destination IP's into a
long, then make a binary tree out of them, then have a further binary tree
of ints representing the source and destination ports coming off each node
in the tree of longs. It seems a bit messy, but it's all I've thought up
thus far.

Assuming I can get the addresses as byte arrays, would just doing this:

public long getAddresses(){
byte[] source=getSource();
byte[] dest=getDest();
long addresses= source[0]|source[1]|...source[7]|dest[0]|dest[1]|...dest[7];
//previous line slightly paraphrased
return addresses;
}

be the best way to go about things? I don't really care about the value of
the longs, I only need to be able to compare them against each other and be
sure that all pairs of addresses will produce a unique value. I also want to
be able to do all this as speedily as possible.

Any help is appreciated

CB








==============================================================================
TOPIC: math.pow rounding problem
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3e00e118892196bb
==============================================================================

== 1 of 2 ==
Date: Sun, Dec 5 2004 3:10 am
From: Patricia Shanahan  

Jimmy zhang wrote:

> Hi, I tried Math.pow(10,-21) and expected to see 1e-21. 
> But instead I saw 1.00000000001e-21. what should I do to
> get rid of the trailing 0.0000000000001??
> 
> Thanks, Jimmy
> 
> 

1e-21 cannot be exactly represented in double, because
doubles are finite-width binary fractions. It is similar to
the problem of representing 2/3 as a finite-width decimal
number.

The default output for Java prints enough digits to
distinguish the result from any other double, which may
include digits that are really meaningless. If the precision
is sufficient, and it is just a cosmetic problem, you could
use DecimalFormat to drop meaningless digits on output.

If you need exact representation of exact decimal fractions, 
such as 1e-21, consider BigDecimal.

Patricia







== 2 of 2 ==
Date: Sun, Dec 5 2004 9:44 am
From: Babu Kalakrishnan  

Patricia Shanahan wrote:
> 
[snip]

Welcome back Patricia. This group certainly missed your expertise during 
the past couple of years. Hope to see you here more often.

BK




==============================================================================
TOPIC: GAP and Java
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cf221d8987d4d5e5
==============================================================================

== 1 of 1 ==
Date: Sat, Dec 4 2004 7:55 pm
From: [EMAIL PROTECTED] 

GAP - http://www.gap-system.org/

Since GAP is written in C and no Java API provided, how can I use my
Java program to "throw" data to GAP for some permutations calculation?
Or any other altnerative solutions available? 

Thanks a lot.





==============================================================================
TOPIC: Java speed vs. C++.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e29354c898cb3523
==============================================================================

== 1 of 10 ==
Date: Sat, Dec 4 2004 7:31 pm
From: Mike Cox  

Hi.  I recently ran a benchmark against two simple programs, one written in
Java and the other in C++.  The both accomplish the same thing, outputting
"Hello World" on my screen.  The C++ program took .5 seconds to complete on
my 400 Mhz PC while the Java program took 6.5 seconds.  

I am running the SUSE 8.2 Linux distribution.

Why is Java that much slower than the C++ program?  I read on Slashdot that
Java was almost as fast as C++.  Here are my programs:

test.cpp

#include <iostream>
using namespace std;
int main()
{
        cout<<"Hello World";
}


test.java

public class test
{
        public static void main(String[] args)
        {
                System.out.println("Hello world");
        }
}

The reason I ask is because I'm thinking of using Apache and Jakarta to do
some development. If Java cannot be speeded up, I will be forced to find
another alternative.







== 2 of 10 ==
Date: Sun, Dec 5 2004 4:25 am
From: "Siemel Naran"  

"Mike Cox" <[EMAIL PROTECTED]> wrote in message

> Hi.  I recently ran a benchmark against two simple programs, one written
in
> Java and the other in C++.  The both accomplish the same thing, outputting
> "Hello World" on my screen.  The C++ program took .5 seconds to complete
on
> my 400 Mhz PC while the Java program took 6.5 seconds.
>
> I am running the SUSE 8.2 Linux distribution.
>
> Why is Java that much slower than the C++ program?  I read on Slashdot
that
> Java was almost as fast as C++.  Here are my programs:
>
> test.cpp
>
> #include <iostream>
> using namespace std;
> int main()
> {
>         cout<<"Hello World";
> }
>
>
> test.java
>
> public class test
> {
>         public static void main(String[] args)
>         {
>                 System.out.println("Hello world");
>         }
> }
>
> The reason I ask is because I'm thinking of using Apache and Jakarta to do
> some development. If Java cannot be speeded up, I will be forced to find
> another alternative.

Maybe it takes time to start up the Java engine, so it will appear to be
much slower for a very short program.  Try a lenghthier test.  Also, the
Java implementation makes a difference too.





== 3 of 10 ==
Date: Sat, Dec 4 2004 7:43 pm
From: Mike Cox  

Siemel Naran wrote:


> 
> Maybe it takes time to start up the Java engine, so it will appear to be
> much slower for a very short program.  Try a lenghthier test.  Also, the
> Java implementation makes a difference too.

Would that be a concern when I use Jakarta to run a web application?  Or
does Jakarta start up and never shut down the engine?



== 4 of 10 ==
Date: Sun, Dec 5 2004 4:36 am
From: "Ann"  


"Siemel Naran" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "Mike Cox" <[EMAIL PROTECTED]> wrote in message
>
> > Hi.  I recently ran a benchmark against two simple programs, one written
> in
> > Java and the other in C++.  The both accomplish the same thing,
outputting
> > "Hello World" on my screen.  The C++ program took .5 seconds to complete
> on
> > my 400 Mhz PC while the Java program took 6.5 seconds.
> >
> > I am running the SUSE 8.2 Linux distribution.
> >
> > Why is Java that much slower than the C++ program?  I read on Slashdot
> that
> > Java was almost as fast as C++.  Here are my programs:

On my machine (WIN XP) it takes at least 5 seconds to start
any program from a dos window that is not built into COMMAND.COM





== 5 of 10 ==
Date: Sun, Dec 5 2004 4:50 am
From: "Ann"  


> The reason I ask is because I'm thinking of using Apache and Jakarta to do
> some development. If Java cannot be speeded up, I will be forced to find
> another alternative.
>
Visual Basic is supported, I tried a "hello world" type program and it
took less than a second including the time to create the window.





== 6 of 10 ==
Date: Sun, Dec 5 2004 10:38 am
From: Arijit  

Ann wrote:

> 
> On my machine (WIN XP) it takes at least 5 seconds to start
> any program from a dos window that is not built into COMMAND.COM
> 

Off topic, but Win XP doesn't even have command.com :)



== 7 of 10 ==
Date: Sat, Dec 4 2004 9:06 pm
From: [EMAIL PROTECTED] 

This message was cancelled from within Mozilla.



== 8 of 10 ==
Date: Sun, Dec 5 2004 5:09 am
From: "Ann"  


"Arijit" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Ann wrote:
>
> >
> > On my machine (WIN XP) it takes at least 5 seconds to start
> > any program from a dos window that is not built into COMMAND.COM
> >
>
> Off topic, but Win XP doesn't even have command.com :)
--------- ya does ---------------
 Volume in drive C has no label.
 Volume Serial Number is 502A-848E

 Directory of C:\WINDOWS\SYSTEM32

08/29/2002  04:00 AM            50,620 COMMAND.COM
               1 File(s)         50,620 bytes
               0 Dir(s)  16,377,466,880 bytes free





== 9 of 10 ==
Date: Sun, Dec 5 2004 12:42 am
From: Sudsy  

Mike Cox wrote:
<snip>
> Why is Java that much slower than the C++ program?  I read on Slashdot that
> Java was almost as fast as C++.  Here are my programs:

Ah, the old "Java is so much slower than C++" premise...

<snip>

Time from main entry to main exit. And all of this is moot if you're using
Apache as it's not (by itself) a servlet container. Think Tomcat!
Suffice it to say that you won't be badly served selecting Java as the
language platform on the server side.

-- 
Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development.




== 10 of 10 ==
Date: Sat, Dec 4 2004 9:01 pm
From: "E. Robert Tisdale"  

Mike Cox wrote:

> I recently ran a benchmark against two simple programs, one written in
> Java and the other in C++.  The both accomplish the same thing, outputting
> "Hello World" on my screen.  The C++ program took .5 seconds to complete on
> my 400 Mhz PC while the Java program took 6.5 seconds.  
> 
> I am running the SUSE 8.2 Linux distribution.

> Why is Java that much slower than the C++ program?

Java programs are almost always almost as fast as C++ programs.
The problem with Java
(and other interpreted languages such as BASIC and MATLB)
is that it doesn't (can't) optimize certain [fine grain] operations
very well even if you compile the byte code into machine code.
This is very well documented in numerical programming.
I used Google

        http://www.google.com/

to search for

        +"Java numerical programming"

and I found lots of stuff.

The bottom line is
You should *not* be afraid to write applications --
even high performance numerical applications --
in Java but be aware that you might run into difficulties
that you just can't work around without calling a routine
written in some other language such as C++.

> I read on Slashdot that Java was almost [always] as fast as C++.
> Here are my programs:

         > cat test.cpp
         #include <iostream>
         int main(int argc, char* argv[]) {
           std::cout << "Hello World" << std::endl;
           return 0;
           }

         > g++ -Wall -ansi -pedantic -o test test.cpp
         > g++ --version
         g++ (GCC) 3.4.1
         > time ./test
         Hello World
         0.003u 0.005s 0:00.00 0.0%      0+0k 0+0io 0pf+0w
         > cat test.java
         public class test {
           public static void main(String[] args) {
             System.out.println("Hello world");
             }
           }

         > javac test.java
         > which javac
         /usr/java/j2sdk1.4.2_05/bin/javac
         > time java test
         Hello world
         0.271u 0.042s 0:00.32 96.8%     0+0k 0+0io 1pf+0w
         > cat /etc/fedora-release
         Fedora Core release 2 (Tettnang)




==============================================================================
TOPIC: Parse Array of Objects - string delimiter java
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6f00a610222e5584
==============================================================================

== 1 of 3 ==
Date: Sat, Dec 4 2004 8:55 pm
From: [EMAIL PROTECTED] (Pedro Rocha) 

How can I parse an object from an array of objects
into a comma delimitted String.

ex:
definition
Cat (String cName, StringcDesc , String cAge)

Cat [] arrayOfCatObjects;

Say I want all the Cat objects into a String (comma delimitted)

something like:
"cat1,stray,8,cat2,bluecat,3"

Any ideas?

thanks



== 2 of 3 ==
Date: Sun, Dec 5 2004 5:05 am
From: "Ann"  


"Pedro Rocha" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> How can I parse an object from an array of objects
> into a comma delimitted String.
>
> ex:
> definition
> Cat (String cName, StringcDesc , String cAge)
>
> Cat [] arrayOfCatObjects;
>
> Say I want all the Cat objects into a String (comma delimitted)
>
> something like:
> "cat1,stray,8,cat2,bluecat,3"
>
> Any ideas?
>
> thanks
---------------not tested ---------------
String catlist;

for (int j = 0; j < Cat.length; j++)
{
  catlist += Cat[j].cName;
}





== 3 of 3 ==
Date: Sun, Dec 5 2004 5:11 am
From: "Ann"  


"Ann" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> "Pedro Rocha" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > How can I parse an object from an array of objects
> > into a comma delimitted String.
> >
> > ex:
> > definition
> > Cat (String cName, StringcDesc , String cAge)
> >
> > Cat [] arrayOfCatObjects;
> >
> > Say I want all the Cat objects into a String (comma delimitted)
> >
> > something like:
> > "cat1,stray,8,cat2,bluecat,3"
> >
> > Any ideas?
> >
> > thanks

oops forgot the comma
---------------still not tested ---------------
String catlist;

for (int j = 0; j < Cat.length; j++)
{
  if(j!=0) catlist += ",";
  catlist += Cat[j].cName;
}






==============================================================================
TOPIC: Javac error.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/21513abc37c9cc4
==============================================================================

== 1 of 1 ==
Date: Sat, Dec 4 2004 10:24 pm
From: Mike Cox  

I have SUSE 8.2.  I'm trying to compile a program that will be used in
jakarta tomcat.  I'm getting this error when I try to compile it with javac
version 1.4.

java:9: package javax.servlet does not exist
import javax.servlet.*;

How do I fix this?




==============================================================================

You received this message because you are subscribed to the Google
Groups "comp.lang.java.programmer" group.

To post to this group, send email to [EMAIL PROTECTED] or
visit http://groups-beta.google.com/group/comp.lang.java.programmer

To unsubscribe from this group, send email to
[EMAIL PROTECTED]

To change the way you get mail from this group, visit:
http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

To report abuse, send email explaining the problem to [EMAIL PROTECTED]

==============================================================================
Google Groups: http://groups-beta.google.com 

Reply via email to