| [iText] template or watermark |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- Referencing the base methodI am creating a new custom JTextField object. I am overwriting my
existing getText() method inside of it. The problem I am having is I
don't know to get the text from the actual text field while I'm in my
new getText() method. I tried casting my object but that didn't work.
so my overall code looked something like this:
public Class CustJTextField extends JTextField {
private int length;
CustJTextField(int length) {
this.length = length
}
public String getText() {
String text = ((JtextField)this).getText()
if (text.length() > length) {
return null;
}
return text
}
}
Thats a much simpler form of what I'm coding, but you should be able to
get the idea. Unfortunately calling the getText method with in my
custom GetText method, ends up with a stack overflow error. Is there
some way to reference the base method? Thanks for any help you guys
can provide
- 1
- Problem with org.eclipse.platform.source_3.1.2/feature.xml on eclipse 3.1.2
I had to manually edit
---
/usr/local/eclipse/features/org.eclipse.platform.source_3.1.2/feature.xml.orig
Tue Jun 6 16:27:12 2006
+++
/usr/local/eclipse/features/org.eclipse.platform.source_3.1.2/feature.xml
Tue Jun 6 16:27:30 2006
@@ -26,6 +26,6 @@
<plugin ws="win32" os="win32" fragment="true" arch="x86"
download-size="0" install-size="0"
id="org.eclipse.platform.source.win32.win32.x86" version="3.1.2"/>
<plugin ws="motif" os="linux" fragment="true" arch="x86"
download-size="0" install-size="0"
id="org.eclipse.platform.source.linux.motif.x86" version="3.1.2"/>
<plugin ws="gtk" os="freebsd" fragment="true" arch="amd64"
download-size="0" install-size="0"
id="org.eclipse.platform.source.freebsd.gtk.amd64" version="3.1.1"/>
- <plugin ws="gtk" os="freebsd" fragment="true" arch="x86"
download-size="0" install-size="0"
id="org.eclipse.platform.source.freebsd.gtk.x86" version="3.1.1"/>
+ <plugin ws="gtk" os="freebsd" fragment="true" arch="x86"
download-size="0" install-size="0"
id="org.eclipse.platform.source.freebsd.gtk.x86" version="3.1.2"/>
<plugin ws="motif" os="freebsd" fragment="true" arch="x86"
download-size="0" install-size="0"
id="org.eclipse.platform.source.freebsd.motif.x86" version="3.1.1"/>
</feature>
in order to set it right. (Configuration now no longer complaints
about missing file).
I am on a fresh FreeBSD 6.1-STABLE #5
with eclipse-3.1.2
--
-Achilleus
- 3
- JMF videoHi
I'm building a multimedia CDROM using Java and JMF for playing video,
audio, etc. on Windows only. I have an interesting problem and am
stuck as to why it's happening and how to resolve it.
Basically, everything is cool on my XP machine. But when I run the
software on earlier Windows (95/8/ME/NT) the video won't play, and I
get an error (not an exception) dumped to the console window saying
that a player cannot be created for the video.
Now I can understand JMF not being able to support certain video
formats, but why does it work on XP but not on the others? I'm using
the same JRE and JMF libraries on all machines, how can this be? Any
ideas or suggestions?
A couple of other related questions:
- if I have to convert the video to a more 'common' format, does
anyone know of any good (and free!) video conversion tools? I've had
a nose round and found WinMPEG, it works for converting AVI to MPEG
but don't seem to like converting the MPEGs I'm using to any other
format.
- the error I get from JMF is dumped to the console, why doesn't it
throw an exception to the standard error stream? can I make it? stupid
JMF!
cheers for any ideas
- sarge
- 3
- Solaris & appletHas anyone had MAJOR and numerous problems running applets which (under
Windows) run fine but under Solaris bomb all over?
I'm shocked that Sun seems to give little heed to how badly applets run (and
how extensive the bug list is) under Solaris.
Am I the only one who has these problems? -Ike
- 3
- javac doesn't find my anonymous classesI'm sorry of this question has been posed and answered many times before.
But I have avoided using the "package" statement because of this.
Most of my classes have no "package" statement, and their class files are
stored in my current directory. Using "javac abc.java" works just fine.
But some of my classes *do* have "package" statements. I try to compile
them with "javac -d . def.java" so that the class file will be stored in a
directory structure.
But def.java refers to some anonymous classes whose class files are stored
in the current directory. The "javac -d . def.java" can't find these
classes. Why not?
My classpath is ".;c:\Sub\Java\JRE", which works fine for my anonymous
classes.
...Ed
- 6
- exception reportHi
When my java application throw an exception, it will connect to
MySQL, dump the exception to it. My java software is open source, so i
scare everyone will know my mysql password because the password is
inside the code.
I can pack the class that connect to mysql to another jar, and don't
release this piece of source code, but this is not open source and not
what i want. Any other way?
thanks
from Peter (email***@***.com)
- 7
- A Business Case for Commons Daemon on FreeBSDGood Day,
I have been working lately with ApacheDS LDAP server and am very impressed
with its design and extensibility. Since it is written in pure Java, it
makes Java geeks like myself quite happy.
I would love to get it running on FreeBSD but unfortunately, it will not
work without a service framework and therefore will not work on FreeBSD :'(
The ApacheDS team has suggested getting a jsvc port for FreeBSD in order to
port over ApacheDS. See Link to post:
http://mail-archives.apache.org/mod_mbox/directory-users/200703.mbox/%email***@***.com%3e
Having Commons Daemon would allow ApacheDS and solutions for Enterprise Java
applications to the FreeBSD platform in a way that they are available
already on Linux. At present, my only options are Linux (hmmm...) or Window
(ack!).
Please let me know how I can help get this port rolling again or help to
expand this business case so we can justify getting this important project
rolling again. I would be quite happy to help in being a tester.
Thanks for your time and interest!
TCQ
For reference, here is the last thread on this topic:
http://lists.freebsd.org/pipermail/freebsd-java/2006-March/005035.htm
- 8
- Java design question: Loosely coupled data extractionOk, so I have a rather complex object hierarchy performing a bunch of
calculations and data manipulations. The hierarchy is populated using
the builder pattern, which worked nice for abstracting away database and
other data fetch mechanisms.
Now time has come to extracting some data from the hierarchy, a report
if you will. I would love to do this in the same loosely coupled way
rather than implementing tree walking logic directly into the nodes of
the hierarchy. My first though was the visitor pattern, as I guess it
would allow me to hook ANY reporting/extracting mechanism up. Does this
sound like a good idea? Are there alternatives you would suggest?
Thanks in advance,
Casper
- 9
- try/catchHi,
jan V wrote:
>>>>If your spouse asks you to get a carton of milk on the way
>>>>home from
>>>>work do you insist s/he substantiate his/her reason?
>>>
>>>I think you're confuse software construction with keeping a
>>>man-woman
>>>relationship happy. I don't see any analogy..
>>
>>It is the employee/employer relationship I was talking about.
>
> You were talking about spouses and cartons of milk. Re-read your own post!
Oh man, Joan compared the communication between spouses with the
communication between an employee and an employer in the software
industry. I think this is not so difficult to understand!
(Although I must admit that I'm interested in who Joan considers to be
the employer and who to be the employee within the marriage! ;-)
Ciao,
Ingo
- 11
- jsp won't compile...I have a jsp that won't compile, I get this error:
An error occurred at line: 30 in the jsp file: /hamlet.jsp
Generated servlet error:
C:\tomcat\work\Catalina\localhost\hamletj\org\apache\jsp\hamlet_jsp.java:77:
';' expected
out.print(iptIn);
^
1 error
HOWEVER: 'out.println(iptIn);' does NOT appear in this jsp!!
entire code for jsp as it stands now:
- - - - - - - - -
<html>
<body>
<%
String hamlet = "Hamlet is sitting on the fence, wondering whether
to be or not to be..";
String ipt = request.getParameter("phrase");
if (hamlet.indexOf(ipt) == -1) {
%>
<div id="phr"> phrase not found.</div>
<%
} else if (hamlet.indexOf(ipt) != -1 && hamlet.indexOf(ipt) > 1 &&
ipt.indexOf("..") == -1) {
int iptL = ipt.length();
int iptPos = hamlet.indexOf(ipt);
int iptPos2 = iptPos - 2;
int iptPos1 = iptPos - 1;
char ipt1 = hamlet.charAt(iptPos1);
char ipt2 = hamlet.charAt(iptPos2);
String iptIn = ipt
+ hamlet.charAt(iptPos + iptL)
+ hamlet.charAt(iptPos + iptL + 1);
%>
<div id="phr">
<%ipt2%><%ipt1%><%=iptIn%>
</div>
<%
}
%>
</body>
</html>
?????????????
I'm trying to do jsp version of this little app (which is done w/a
servlet..) http://www.francesdelrio.com/hamlet/
thank you very much!! Frances
- 11
- 12
- Question regarding JDK 1.5 MakefileHi there,
Is it possible to split the choice between WITHOUT_WEB
to WITHOUT_PLUGIN and WITHOUT_WEBSTART? I would like to
be able to have Java Webstart working, but I don't really
want to install Mozilla ;)
Any thoughts?
Kind regards,
-------
Manfred Riem
email***@***.com
http://www.manorrock.org/
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 13
- how to populate the tomcat http request with account nameWe have a Tomcat application in which each request is routed via IIS
(isapi-redirect)
IIS populates a parameter with the
active directory account name.
This is then available in Tomcat to authenticate via a call
to Active Directory.
Without the account name I cannot see how we can authenticate.
I am hoping someone can suggest an alternative way to providing
the account name without using IIS?
I have seen 3rd party products that support single sign on such as
Vintela
but these would appear to depend on the account name being
provided in the request.
- 16
- constructor style?A quick question about constructor style:
Which do you prefer, independently built constructors or nested
constructors?
eg.
// Eclipse automatically generated style
AClass() {
}
AClass(String str) {
this.str = str;
}
AClass(String str, int num) {
this.str = str;
this.num = num;
}
or
// "Elements of Java Style" recommended style
AClass(String str, int num) {
this.string = string;
this.num = num;
}
AClass(String str) {
this(str, DEFAULT_NUM);
}
AClass() {
this("", DEFAULT_NUM);
}
- 16
- Hibernate and Date objectsHi everyone,
I'm having a frustrating time working with Date objects and Hibernate
with an Oracle database.
I have a Patient class containing a Date field (java.util.Date)
and the mapping in the hbm.xml file:
<property name="regDate" type="date">
<column name="REGISTRATION_DATE" />
</property>
When I try and commit a new object to the database, I get a
ClassCastException with the following backtrace:
java.lang.ClassCastException
at
net.sf.hibernate.type.TimestampType.deepCopyNotNull(TimestampType.java:63)
at
net.sf.hibernate.type.NullableType.deepCopy(NullableType.java:96)
at net.sf.hibernate.type.TypeFactory.deepCopy(TypeFactory.java:212)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:935)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:866)
at
net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:788)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:747)
at com.sleep.PatientHandler.doPost(PatientHandler.java:96)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:534)
Is this something to do with casting (and failing) an java.sql.Date to a
java.util.Date or something similar?
If anyone can shed any light on this, or has had a similar problem, it
would be greatly appreciated!
Cheers,
Chris.
|
| Author |
Message |
Ingo R. Homann

|
Posted: 2005-8-2 22:28:00 |
Top |
java-programmer, [iText] template or watermark
Hi,
I remember that with iText it is possible to use an existing PDF
document als template or "background image" for a new PDF document. IIRC
it could be done using some watermark- or template-functions?
(Unfortunately, the old documentation has ben abandoned...)
Anyway, I've got a document, and I could add a template to its
PdfContentByte. Furthermore, I have a PDFReader with which I've read the
existing document. But I don't know, how to get a template from the reader.
Or can this only be solved in a completely differnt way?
Ciao,
Ingo
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Wholesale Swiss Rolex Oyster Perpetual DateJust White Gold-ss Men's Watches SRX024 Discount, Fake WatchWholesale Swiss Rolex Oyster Perpetual DateJust White Gold-ss Men's
Watches SRX024 Discount, Fake Watch
Wholesale Watches at www.watchec.com
Browse our Swiss Rolex Oyster Perpetual DateJust White Gold-ss Men's
Watches fake watch, which is sure the watch you are looking for at low
price. There are more high quality designer watch replicas for
selection
Swiss Rolex Oyster Perpetual DateJust White Gold-ss Men's Watches
SRX024 Link :
http://www.watchec.com/swiss-rolex-datejust-replica-watches-srx024.html
Model : SRX024
Description : 100% Genuine Replica Swiss Rolex Watches,
Sale Price : $ 319.00
Swiss Rolex Oyster Perpetual DateJust White Gold-ss Men's Watches
SRX024 Details :
Automatic movement
Hack mechanism (second hand stops when crown is pulled out to set the
time ?standard feature on all genuine Rolex watches)
Sapphire crystal watchglass
Screws in the links, not pins
Rubber seal at trip-lock winding crown
Serial band/number on last link/lugs
Standard Jubilee-band clasp, with serial number and steelinox markings
on clasp
Full Stainless Steel band/case, and will never fade or wear
Solid back with characteristic Rolex green sticker
Screw-in watch crown
All the appropriate Rolex markings in the correct places
We are leading supplier of Wholesale watches including rolex watches,
rolex submariner, rolex daytona, rolex thunderbird, rolex tudor, rolex
oyster, rolex yacht master, swiss pendant watch, rolex sea dweller and
rolex air king etc. We are specialized fashion Watches wholesaler.
If you are looking for the well know brand watch and information about
it, you came to the right place. Here you can find such fine you I top
brand-name watches as Well know brand Rolex Watches, Well know brand
Alain Silberstein Watch,Fake A.Lange & Sohne watch,Well know brand
Audemars Piguet Watches, Baume & Mercier watches, Replica Jacob & Co
watches, well know brand Breitling watches, Well know brand Breguet
watch, Bvlgari, Jaeger leCoultre, and other.
Man watch is the most important accessory a man can own - it is an
essential style element. Well know brand watches are invented for the
people who want to look good, to impress everybody, but they don't
have so much money to buy original expensive watch. Our well know
brand watches are well known for their impeccable quality, the
precision engineering of the watches. Nobody will ever know that it is
not real. Also, it is a very good, pleasant and not expensive present
for your friend, father, husband, wife or any other close person,
witch will serve for many years. This great present will remind about
you to your close man every time. If you are looking for luxury, the
latest watch technology and excellent design take a look at our
collection of well know brand watches.
If you have any other questions please check our other pages or feel
free to email us by email***@***.com
Wholesale Swiss Rolex Oyster Perpetual DateJust White Gold-ss Men's
Watches SRX024 Discount, Fake Watch
- 2
- implicit <? super T> when an array is a parameter in a generic methodi'm making some adjustments to previous code to utilize generics in java
1.5 or 5.0 or whatever it is called. something seems inconsistent,
though:
let us say i have a method that operates on two collections:
public <T> void testMethod(Collection<T> c1, Collection<T> c2){...}
if i call this method with the following line, a compile-time error
occurs:
testMethod(new HashSet<Integer>(), new HashSet<Number>());
and rightly so. in this case T != T (i.e. Integer != Number).
the method would have to be rewritten to:
public <T> void testMethod(Collection<T> c1, Collection<? super T>
c2){...}
and this indeed works. this is fine and quite logical.
now the problem. let us assume i have a method that copies elements
from an array into a collection:
public <T> void testMethod(T[] a, Collection<T> c){...}
suddenly i'm allowed to call this method with T != T, as in:
testMethod(new Integer[100], new HashSet<Number>());
the official word from sun is: "it will generally infer the most
specific type argument that will make the call type-correct." apparently this
line is only in reference to arrays (although they don't mention that).
so when this "inferring" occurs, is there basically a re-writing going
on the background that equates to changing the function to:
public <T> void testMethod(T[] a, Collection<? super T> c){...}
?
i guess the true root of the question is, which of the parameters (and
indeed there may be many) will be going through the inferring process?
there must be at least one "baseline" argument type parameter in calls
like these that remains fixed (i.e. cannot go through an inferring
process), because otherwise every type argument could just be inferred to be
Object, making all calls legit and ruining the advantage of generics.
wow, that may have been a bit confusing, but if anyone would point me to
a general good source on java's version of generics (not sun's
documents, as i've already tried to read those and they don't clear up this
confusion at all), it would be greatly appreciated.
thanks,
murat
- 3
- 4
- Creating a pop-up messageIs there a way to have a text file or an excel file and in it list
dates and a message, then having my web page reference that file and
pop up with the message if the current date matches a date in my file.
- 5
- Where did Castor go?The www.castor.org project seems to be gone. I loved this XML-Java
binding framework and I am wondering if anyone are aware of what has
happened to it?!
Thanks,
Casper
- 6
- SAX: continue parsing in included file(s)Currently I use <include>foo.xml</include> [1] in order to include foo.xml
into bar.xml (for example). Since I am moving the parsing to Java, using
SAX I was wondering what the best way is to implement this feature. How do
I "redirect" the reading to another file via a handler?
IIRC, another option might be to use &foo; [2] and include the file that
way, possible combined with a SAX filter to translate <include>foo.xml
</include> into &foo; ?
Any suggestions?
[1] I used in the past a parser (not with Java) that as far as I know was
not able to handle this:
[2] <!ENTITY foo SYSTEM "foo.xml"> , see
http://xml.silmaril.ie/authors/includes/
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
- 7
- this is a known bug (bug_id=6263423)
Hi,
after some research in the bug database i found that this is a
known bug with the print margins.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6263423
It seems that it doesnt matter whether one uses the native page
setup dialog (PrinterJob.pageDialog(PageFormat)) or whether
one uses the cross-platform Java page setup dialog
(PrinterJob.pageDialog(PrintRequestAttributeSet)).
Now i dont use a page setup dialog anymore, and use fix margins.
:)
regards
Oliver
- 8
- squeezing the use of memoryHi,
Qick question about the use of int Vs. the use of short,char,byte
in 'for' loops. Will it affect the memory utilization/performance at all ?
If yes, to what extent, especially considering a program which uses
looping extensively and doesn't need the entire 'int' range.
Generally people just go ahead and use 'int' in loops...
Awaiting your thoughts,
Asif
- 9
- how do I use String's format? not working on XPimport java.lang.String;
...
public void paint(Graphics g) {
Graphics2D comp2d = (Graphics2D)g;
Dimension appletSize = this.getSize();
appletsize_x = appletSize.width;
appletsize_y = appletSize.height;
String sx=String.format("%d", appletsize_x);
String sy=String.format("%d", appletsize_y);
g.drawString(sx, 200,30);
g.drawString(sy, 200,60);
g.setColor(Color.red);
g.fillOval(x_pos - radius, y_pos - radius, 2*radius, 2*radius);
}
...
}
ballapplet.java:101: cannot resolve symbol
symbol : method format (java.lang.String,int)
location: class java.lang.String
String sx=String.format("%d", appletsize_x);
^
ballapplet.java:102: cannot resolve symbol
symbol : method format (java.lang.String,int)
location: class java.lang.String
String sy=String.format("%d", appletsize_y);
^
2 errors
--
------------------------------------
Jim Michaels
for email, edit the address
RAM Disk is *not* an installation method.
- 10
- SwingUtilities.getRoot() in a javax.swing.ActionAfter reading
http://www.exampledepot.com/egs/javax.swing/frame_FrameFind.html
I wrote a small test program in which I found that
SwingUtilities.getRoot() returns null. getRoot() works well for me in
other programs when I feed it a container (e.g. JPanel).
What am I doing wrong? Cannot SwingUtilities trace the JFrame to which
the JMenuItems are ultimately attached? Why not?
------------------------------------8<-------------------------------
import java.awt.Component;
import java.awt.event.ActionEvent;
import javax.swing.*;
public class EnumAction {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new EnumAction();
}
});
}
EnumAction() {
JMenu m = new JMenu("Menu");
for (Command c : Command.values())
m.add(new JMenuItem(c.action));
JMenuBar mb = new JMenuBar();
mb.add(m);
JPanel p = new JPanel();
p.add(new JLabel("EnumAction"));
JFrame f = new JFrame("EnumAction");
f.setJMenuBar(mb);
f.add(p);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.pack();
f.setVisible(true);
}
}
enum Command {
CMD_THIS("This"), CMD_THAT("That");
Action action;
Command(final String label) {
action = new AbstractAction() {
{
putValue(Action.ACTION_COMMAND_KEY, name());
putValue(Action.NAME, label);
}
public void actionPerformed(ActionEvent event) {
System.out.println(event.getActionCommand());
Object o = event.getSource();
if (o instanceof JMenuItem) {
Component c = SwingUtilities.getRoot((JMenuItem)o);
System.out.println("Root: "+c);
}
}
};
}
}
------------------------------------8<-------------------------------
- 11
- void method? Hello,
I am not sure were to put the return, i want to return the sum of the 3
digits, but it gives me an error becouse, it expect a void method
Irlan
public static void main(String[] args) {
//declareer getal
long getal = 456;
//invoke method
Sumdigits(getal);
}
//method declaration
public static int Sumdigits(long n){
int num2 = (int)n % 10;
int num1 = (int)n / 10;
int num0 = (int)num1 % 10;
int num100 = (int)n / 100;
return
System.out.println("de sum is" +num2+ "+" + num0 + "+" +num100);
}
}
- 12
- Getting value of variable from Thread to main classI have a problem, with getting value of a variable that is set in
thread. I start the Thread in a main class, thread gets the value from
server and sets it as static variable. After starting the thread I try
to print the value of " threadObjetc.staticvariable " but every time
it has a null value. I suppose that the reason for that is that thread
works in a background and functions of main class continues anyway. If
someone had a similar problem and could help me to avoid it I would be
gratefull for help, Thanks
- 13
- Binomial Simulation-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'm taking a class in Evolutionary Computation. I just turned in an
assignment that implements a simple genetic algorithm based on bit
strings. For mutation I simply check each bit in the population and
flip it with some constant probability. For a population of 10,000
individuals of 100 bits that means that I have to execute the method
Random.nextDouble() 1,000,000 times. I thought about this a bit and I
could do the same operation by getting a single value from a binomial
distribution and then selecting that number of bits at random. This
would require far fewer operations that the current brute force method.
For real problems this might not matter that much since mutation would
take a small percentage of the time spent in the algorithm, but for my
test problems mutation is the biggest contributor to run time.
So, now to the question. Is there an open source implementation of
nextBinomial() out there somewhere? I did a quick search of the web and
didn't find one. I could implement my own, but it probably wouldn't be
as fast as a widely used open source implementation and I don't want to
spend the time on something that is really a library function if I don't
have to.
Note that I'm not trying to cheat here. If I end up using it in an
assignment I will credit the author and the prof won't mind. This is a
graduate course.
Thank you.
- --
Kenneth P. Turvey <email***@***.com>
http://kt.squeakydolphin.com (not much there yet)
Jabber IM: email***@***.com
Phone: (314) 255-2199
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFDRwbHi2ZgbrTULjoRAkxhAJsEm9g5EfvsY9P7bnE9E3czsTgsDQCg9Glz
pS2dmdxSYVmjUcfpFpUSt9A=
=vcUC
-----END PGP SIGNATURE-----
- 14
- synchronized confusion!hi all!
If a method is synchronized like this:
public synchronized void broadcast (String message) {
I have like 10 threads calling the broadcast method.
What happens to all threads calling this method?
Does the threads halt/wait and line up in a qeueue??
Is it like when one use the Wait-notify system or what.
Does the threads stop what they are doing when they
try to get access to the synchronized method and the method
is locked.
I know that when I use the wait() it will put
thread's in the Wait mode. I can then do a notify/all
and the waiting threds will continue. This is easy to
understand. But the synchronized is not like that I guess
Hope you understand what I mean!
- 15
- Applet Issues!!Hey, Im Attempting to create an applet that will open a connection to my
application server, the application server WILL be on the same machine
that the applet will be loaded from, i.e. the app server is on the same
machine as the web server. here is my code (sorry for the bad standards)
public class ClientConference extends Applet {
private ObjectOutputStream output;
private ObjectInputStream input;
private String message = "";
private String chatServer;
private Socket client;
//----------------------------------------------------------------------//
public ClientConference( String host ) {
chatServer = host;
ClientConference application;
application = new ClientConference( "149.153.130.2" );
application.runClient();
}
//----------------------------------------------------------------------//
private void runClient() {
try {
connectToServer(); // Step 1: Create a Socket to make connection
getStreams(); // Step 2: Get the input and output streams
processConnection(); // Step 3: Process connection
}
// server closed connection
catch ( EOFException eofException ) {
System.err.println( "Client terminated connection" );
}
// process problems communicating with server
catch ( IOException ioException ) {
ioException.printStackTrace();
}
finally {
closeConnection(); // Step 4: Close connection
}
} // end method runClient
//----------------------------------------------------------------------//
private void connectToServer() throws IOException{
client = new Socket( InetAddress.getByName(chatServer), 8000 );
}
//----------------------------------------------------------------------//
private void getStreams() throws IOException{
output = new ObjectOutputStream( client.getOutputStream() );
output.flush();
input = new ObjectInputStream( client.getInputStream() );
output.writeObject( "Client Connected" );
output.flush();
}
//----------------------------------------------------------------------//
private void processConnection() throws IOException{
do { // process messages sent from server
// read message and display it
try {
message = ( String ) input.readObject();
}
catch ( ClassNotFoundException classNotFoundException ) { }
} while ( !message.equals( "TERMINATE" ) );
}
//----------------------------------------------------------------------//
private void closeConnection(){
try {
output.close();
input.close();
client.close();
}
catch( IOException ioException ) {
ioException.printStackTrace();
}
}
//----------------------------------------------------------------------//
private void sendData( String message )
{
// send object to server
try {
output.writeObject( "CLIENT>>> " + message );
output.flush();
}
// process problems sending object
catch ( IOException ioException ) { }
}
//----------------------------------------------------------------------//
} // end class Client
If anyone could even hasard a guess at the issue I would appreceate it,
also here is output from the java console if its anyhelp.
load: ClientConference.class can't be instantiated.
java.lang.InstantiationException: ClientConference
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Thanks in advance I really appreceate any help
Niall
|
|
|