Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

Joseph Macer

Ranch Hand
since Apr 20, 2008
Cows and Likes
Cows
0
In last 30 days
0
Total given
0
Likes
0
0
Total given
0
Given in last 30 days
0
Scavenger Hunt
Ranch Hand Scavenger Hunt
Greenhorn Scavenger Hunt

Recent posts by Joseph Macer

I stand corrected!
11 years ago

1)You have 10 marbles and one is heavy. How many minimum iterations are needed to find the heavy marble.
2) There are two jars of capacity 5 and 3 liter. How to measure 7 liter of water using these two jars.

The first question gives incomplete data. If you assumed one marble is of weight X and the other nine are of weight <X, the question is about search efficiency; in this case I suspect they are looking for someone to do a binary-like search: comparing 5 marbles to the other five, discarding the lighter pile, comparing two of those to another two, and either selecting the odd marble out if both sets of two or equal, or comparing one of those sets. This gives you a minimum of 2 iterations (for best-case; 3 iterations to select the heaviest marble no matter the situation). If the marbles are of arbitrary weight and you need to find the heaviest, then the answer is completely different.
To clarify:
1) Compare 5 marbles to another 5. The heavier pile contains the heavy marble. Discard the lighter pile.
2) From the heavy pile, compare any 2 marbles with any other 2.
IF the same piles are the same weight, the heavy marble is the one you're not holding. The end.
3) ELSE, compare the two marbles from the heavier set found in step 2. The end.

The second question has already been answered, assuming infinite supply of water:
-Fill 5 liter jar to capacity
-From the 5 liter jar, fill the 3 liter jar to capacity
-Empty the 3 liter jar
-From the 5 liter jar, transfer the remaining 2 liters to the 3 liter jar
-Fill the 5 liter jar to capacity
You now have 5L in a five liter jar, and 2L in a three liter jar.
11 years ago
I think, with my layman understanding of this, that you would need to have the client install an application that registers a URL type for browsers. For example see:
Where clicking something like "ventrilo://www.myserver.com:3784/servername=MyServer"; would run an application with that resource call.

Unless significant work went into making this interaction graceful, it strikes me as a very inelegant solution. I would suggest you look hard at what you're trying to do, and brainstorm more unified ways to approach the problem.
11 years ago
11 years ago
To make a rough test of throughput, simply create a huge object and transfer it through an ObjectOutputStream and time it with System.nanotime(). Or, generate a large text file and use a reader to push that through a stream. However, there are myramid reasons your results could be off, such as Comcast's powerboost or whatever they call it.

Any particular reason you want a bandwidth test? Professionals have done it a lot better, and their results will be an order of magnitude more accurate and repeatable.
11 years ago
Recently, Java and FF had some problems working well together - I had the same problem with FF not loading the applet and IE. Updating to JRE update 12 fixed it.
11 years ago
If I understand you correctly, you're trying to have an applet write out to a file, based on network interaction with some other JVM on another machine. It seems that you have correctly removed the security policy from the equation for now. I'll try to answer your questions based on what I understand about your questions:

Q1: Yes, you can have an applet loaded from a webserver. If you write an applet, you can, for example, just slap it in the www folder of a default installation of Apache & it'll work! If you've had the applet signed & got a security policy it'll run in a browser. I have my applet running without being signed and a barebones security policy.
Q2.0: Webstart is good for deploying desktop solutions over the internet, which sounds like what you don't want to do.
Q2.1: That is up to the user and the browser, as it should be. Either it will ask, or expressly prevent it. In most cases, applets write to the filesystem through a protected cache, which is more common and might be more useful to you.
Q3: n/a
Q4: Not quite sure, you'll have to google it.
Q5: CA certs cost money, and self-signed certs trigger flags in some browsers. Plus, self-signed certs do NOT guarantee identity, just the the person using the cert is the same person every time. So unless your users must be mathematically sure that you are the same author every time, I'd say don't bother. But that's me being a casual small-timer.

Hope this all helps!
11 years ago
Simply googling "exe to msi" will reveal dozens of software solutions for this. Most use a program that simply adds a MSI wrapper around the EXE, for more advanced options you'll want to delve into the official Microsoft documentation.
11 years ago
One of java's best and worst points is that it complies to machine-independent code, as opposed to C++. Due to the nature of the language, any hardware-specific tool would tie the code to a particular platform, eliminating one of the biggest selling points of the language. Because of this, I suspect you will have a hard time finding a vendor who will do what you're looking for.
11 years ago
You'll need to be a bit more specific. A simple way to search a text file of arbitrary size is to simply step through it looking for a keyword. If you're getting an exception due to being out of memory, you have a memory leak somewhere, or are trying to read through the whole file at once.

For any operation, you can typically be efficient with time, memory, or I/O - usually you get to pick two of those three. If you don't have enough memory to do it quickly, you will take longer to do it a different way.
11 years ago
As Jeanne mentioned, the JDBC is a good way to deal with databases. I use JDBC to perform all sorts of operations on a MySQL database without much trouble. Since you're storing a file, you could simple open a stream to the file like normal and read it directly into a String, for example, and save the String into a BLOB.
11 years ago