Tetsuo Suzuki

Greenhorn
+ Follow
since Feb 21, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tetsuo Suzuki

Hey everyone, I think I found a solution and will post it in case anyone searching hits the question:

It is possible to detect the proxy using the [ProxySelector][1] class and assign the system proxy by assigning environment variables with the [setProperty method of the System class][2]:

System.setProperty("java.net.useSystemProxies", "true");
System.out.println("detecting proxies");
List l = null;
try {
l = ProxySelector.getDefault().select(new URI("http://foo/bar"));
}
catch (URISyntaxException e) {
e.printStackTrace();
}
if (l != null) {
for (Iterator iter = l.iterator(); iter.hasNext() {
java.net.Proxy proxy = (java.net.Proxy) iter.next();
System.out.println("proxy hostname : " + proxy.type());

InetSocketAddress addr = (InetSocketAddress) proxy.address();

if (addr == null) {
System.out.println("No Proxy");
} else {
System.out.println("proxy hostname : " + addr.getHostName());
System.setProperty("http.proxyHost", addr.getHostName());
System.out.println("proxy port : " + addr.getPort());
System.setProperty("http.proxyPort", Integer.toString(addr.getPort()));
}
}
}


[1]: http://java.sun.com/j2se/1.5.0/docs/api/java/net/ProxySelector.html
[2]: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#setProperty(java.lang.String,%20java.lang.String)
12 years ago
Hey everyone,

In a java program how one can utilize the proxy that is already configured (on Windows, I assume it would be the same everywhere (write once, run... ?)).

Here is a demonstration of my issue:

1. Go to your Control Panel->Java and set a proxy address.
2. Run the following simple applet code (I'm using the Eclipse IDE):

import java.awt.Graphics;
import javax.swing.JApplet;
import java.util.*;

public class Ranchlet extends JApplet {
private String message;
public void init(){
Properties props = System.getProperties();
message = props.getProperty("http.proxyHost", "NONE");
message = (message.length() == 0)? "NONE": message;
}

public void paint(Graphics g)
{
g.drawString(message, 20, 20);
}
}

The Applet displays "NONE" without regard to the settings you've placed in the Java Control Panel. What would be best would be if the Windows proxy settings (usually set in Internet Explorer) were what I could determine but doing an extra configuration step in the Java Control Panel would still be an acceptable solution.

Thanks!
12 years ago
Hello all,
My first question -
I was wondering if the JDK 1.4 now does JIT compilation or if bytecode is still interpreted.
I also wondered -
I went to a presentation of JBuilder 7 and saw that the tool could generate .exe files out of .jar files. Is this a "precompilation" feature from SUN or is it a perk of JBuilder?
thanks much,
tetsuo
the lone wanderer
19 years ago
Hello all. I need to write a scrolling applet for some content on a website I'm working on. I've looked at some of the free scroll applets out there but they are not flexible enough for me and all 'closed source'.
I tried to use a thread with a looping 'repaint()' where I had a paint method that looked something like this:

The above doesn't redisplay the text, in fact I get a blank screen. Can anyone point me in the right direction or tell me where some samples are? Is it better to scroll in a component like a textfield?
Thanks much
Tetsuo!
19 years ago
Americans vs. Soccer has many dimmensions:
1. They don't understand the game
[Just like the rest of the world doesn't understand baseball]
2. It doesn't market well [no timeouts for beer advertisements].
3. They've never played it [can't notice intricacy or appreciate skills]
4. The rest of the world plays soccer because it doesn't require the facilities of basketball (rim, shoes, court), football (pads, helmet, pigskin) or baseball (bats, gloves, etc..).
/*********************/
I think soccer is the best sport for intuition. The decision making process in a game is never static - the plays aren't closely controlled by one single manager or coach. As players run to open space or create opportunities they are left to how well they understand the game, their opponent, their teammates and the situation.
The story is not just the score - the story is the process. In basketball you may see Kobe Bryant face up one on one and have about 3 seconds of intuitive decision making but in soccer each player does this for 90 minutes! Unparalleled.
/*****************************/
I don't know who I should go for. My country (Uganda) isn't going to have any national sports teams go anywhere in the forseeable future.
I think I'm going to have to go with Brazil although woeful defending makes me want to pick a European team for a championship.
I'd go for Germany, especially since they now have an immigrants playing for them from Africa. It's cool that Miloslav is an immigrant too. And Rudy Voller, blast from the past.
Well, anyway I'm mumbling.
>>Tetsuo!!
19 years ago
What exactly is meant by:

I know that {...} is for an array literal, so it makes sense that is an array of type Class. Is this an array of the Boolean wrapper class? On the 3rd line, where it references new Class[0], I also am not sure what is meant.
Javabeans blues...
Tetsuo!
19 years ago
Why does it balk when trying to reference a single field more than once?
1.
ResultSet students = s.executeQuery("Select...");
students.next();
String f = students.getString(1);
String first = students.getString(1); // error
2.
Are you able to use the different scrolling options with the JDBC-ODBC bridge? Every time I tried I got a big fat exception.
3.
What's up with only having one ResultSet open?
Does anyone know of a plausible driver to use with Access?
Why doesn't Sun ship a free workable driver
? That would make java much more friendly and appealling. It would also create something of a standard, instead of having to deal with JDBC implementation nuances.
Questions, questions, questions...
Oops -> found the answer to my question. ResultSetMetaData interface provides a getColumnCount() method.
Ironically enough I found the solution by googling and looking at how .NET data access works. Very similar to Java.
Hm...
Is there a method in the JDBC ResultSet interface that can get the number of columns returned from a query?
Apologies if this question has been asked before...
Tetsuo!
Ran into something a bit strange; if I have a component array it won't allow me to initialize each component outside of the constructor. An example of what I mean:

But...

Is assigning the 'new' keyword here doing something executable that can't be in declaration?
Thanks much,
Tetsuo!
19 years ago
Does anyone know if the Windows JVM uses Native threads? Also, if I get a native compiler for java, will it then use Native threads for sure?
Thanks,
Tetsuo!
When does java use native threads and when does it use green threads? Does it depend on what platform a person is using? Or their compiler?
Thanks in advance,
Tetsuo!
Okay, I was under the assumption that the setPage method would retrieve the content and display it in the JEditorPane...
19 years ago
Hey all,
What does it take to be more than a greenhorn? Anyway, I've got the following class. Unfortunately, every time I try and run it it gives me a connection timeout error. I looked in the java api docs but find nothing about timeouts related to the JEditorPane. Thanks much,
Tetsuo!
>> Code follows...
19 years ago
Hey all, a few questions about exception handling in java.
First off: I understand that the finally{} block is meant to execute regardless of success or failure in the try{} block. So if I have the following:

This is by the book but strangely enough if I have the following:

Are there only certain circumstances where the finally block is essential to run code after an exception has been caught in a catch block? Or is it a matter of surety that code will run regardless of success or failure?
Question 2:
If I have a method:

I get a compile error if I try to use the method without an exception handler.
BUT...
if I have a method:

Java lets me compile without an exception handler when calling the method. Wierd, has anyone else run into this?
Tetsuo!
19 years ago