masijade 1,351 Industrious Poster Team Colleague Featured Poster

If you will notice, there is a lot more than just "processor speed" mentioned there.

Network is a big one. "out" is not your problem, if you even have one.

Especially since W1 for server and client means there is no network, so no network latency, or capacity limitations. Try placing your "server" and "client" on different windows machines, that have approximately the same network "distance" as there is now between your client and the Solaris server, and then see how long the "out.println" takes from the Windows server.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Different processing speeds?

I mean, really, the question means about nothing.

What are the relative Processor Speeds, the relative network interface throughput, the relative hardware threading capability, the relative memory speed, the relative diskspeed, etc, etc, etc, etc, etc, (I think you, maybe, get the point).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

That is a Sybase question.

www.sybase.com/support/community-forums

masijade 1,351 Industrious Poster Team Colleague Featured Poster

"jdbc:odbc:<DB>" not "jdbcdbc:<DB>"

You also need to configure your DSN (Google for that or ask at a Microsoft forum), and adding the Microsoft Access Driver does no good. Netbeans/Java is not using that, it is an ODBC Driver. Java is using the JDBC-ODBC Bridge which bridges to ODBC Drivers.

Now, all that being siad, if you want a DSNless connection (i.e. you don't want to have to configure a DSN on any system using the app), then do

"jdbc:odbc:Driver={Microsoft Access Driver(*.mdb)};DBQ=<full path to mdb file>;Uid=;Pwd=;"

Edit: The DB Driver (i.e. the JDBC-ODBC Bridge driver) that you do need to configure in Netbeans (instead of the Microsoft ODBC Driver) is "sun.jdbc.odbc.JdbcOdbcDriver"

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I don't believe so (although you can try with HTML marked text as with JLabel, but I don't think it works for a textarea).

Check out JEditorPane.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I have no idea what it is you want. If it is that you want to develop Servlets and JSP's then you have what you need.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Initialise your high/low variables like this

int highest = Integer.MIN_VALUE;
int lowest = Integer.MAX_VALUE;

and you can't go wrong. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Seeing the code (or at least parts of it) might help. But, if there were any "problem" (and there probably is), then you would get an error message, unless of you're catching the Exception and ignoring it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, I used DB, but substitute <generic server> for DB and the point remains the same. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Sorry if you thought I was aiming at you. I wasn't. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Aside from the fact that he is wrong. ;-)

Doing that will lead to an "unreachable code" error, as well as a "missing return statement" error, because both return statements are inside the original if, and the first line of that if block is a return statement, which would make the rest of it unreachable, and if the "if" is false, there would be no return. As I said, simply change the { after return calcSummerCost(); to a }.

P.S. you can also change "if (!s)" to "else" if you wish, or simply delete that statement and the { and } after it (although not the contents between them), as well (in addition to the afore mentioned brace change, of course).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

As crazy (verruckt is crazy in German, which I assume crazy knows, but maybe it was just coincidence) says, it comes when there is nothing listening at the address:port combination that you attempt to connect to. That could be because the db is not running, or is not configured to accept TCP/IP connections, or is listening on a different port, or is running on a different server altogether, or that there is a firewall in the middle that actually rejects connection attempts rather than simply letting them silently drop.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Post your new code.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay, so if the first label is at 20 and has a height of 200 where does the next label need to be?

Edit: And, there is also the fact that you are using the same label everytime, you, obviously, need to move the creation (and, of course the bound setting) inside the while loop.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, lets look at what you're doing

t1.setBounds(20,20,200,200);

What is the first 20 there?
What is the second 20?
What is the first 200?
What is the second 200?

P.S. Look at the API docs for Component.
Once you know what those stand for think about how someone might shift the next label down far enough to be below (rather than on top of) the previous label. Then try something. If you don't get it right post what you tried and we'll help you correct it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It prints that message because it is catching an exception and that is what you are telling it to print. Add a stacktrace to that catch block and try again, so that you at least know what is going wrong.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It is displaying every row but

t1.setBounds(20,20,200,200);

when you put every label in exactly the same place you only see the last one.

I assume you are using the "so-called" null layout? If so, why? That is, usually, the worst thing you can do to your GUI. Don't use it unless you have a really good reason, and you know what you are doing.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

That's even worse. So we're to simply earn you a completion you don't deserve so that somebody else (possibly the one giving the answer) then also has to do your work for your ignorant self so you get paid, since you won't know how to do it yourself.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Just for Fun, I decided to actually set it up last night, and sat down for about an hour, and here it is

package test;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.JarFile;
import java.util.jar.Manifest;

public class JarStarter extends Thread {

	private File f;
	private JarFile jf;

	public JarStarter(File f) throws IOException {
		this.f = f;
		try {
			jf = new JarFile(f);
		} catch (IOException ioe) {
			System.err.println("Error loading JarFile.");
			jf = null;
			throw ioe;
		}
	}

	public void run() {
		if (jf == null) return;  // Should never be possible, but ....
		try {
			String mainClass = getMainClass();
			if ((mainClass == null) || (mainClass.trim().length() == 0)) return;
			ClassLoader cl = createClassLoader(getClassPath());
			if (cl == null) return;
			setContextClassLoader(cl);
			Class<?> c = cl.loadClass(mainClass);
			c.getMethod("main", String[].class).invoke(null, (Object) new String[0]);
		} catch (InvocationTargetException ite) {
			ite.printStackTrace();
		} catch (IllegalAccessException iae) {
			iae.printStackTrace();
		} catch (NoSuchMethodException nsme) {
			nsme.printStackTrace();
		} catch (ClassNotFoundException cnfe) {
			cnfe.printStackTrace();
		} catch (IOException ioe) {
			ioe.printStackTrace();
		} finally {
			try { jf.close(); } catch (IOException ioe) {}
		}
	}

	private String getMainClass() throws IOException {
		Manifest man = jf.getManifest();
		return man.getMainAttributes().getValue("Main-Class");
	}

	private String[] getClassPath() throws IOException {
		Manifest man = jf.getManifest();
		String classpath = man.getMainAttributes().getValue("Class-Path");
		if (classpath == null) return new String[0];
		return classpath.split("\\s+");
	}

	private ClassLoader createClassLoader(String[] items) {
		String dir = f.getParentFile().getAbsolutePath();

		List<URL> urls = new ArrayList<URL>();
		try {
			urls.add(f.toURL());
			for (String item : items) {
				urls.add(new File(dir + item).toURL());
			}
		} catch (MalformedURLException murle) …
masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

When properly formatted

public double getTotal()
  {
    if (s)
    {
      return calcSummerCost();
      {
        if (!s)
        {
          return calcWinterCost();
        }
      }
    }

Do you see your problem?

I have the feeling that you used the wrong brace after return calcSummerCost();

masijade 1,351 Industrious Poster Team Colleague Featured Poster

wud be nice <3

No it wouldn't.

You might think would be, but how would that help you on your next assignment, which is meant to build on what you learned in this assignment? If someone does it for you, you haven't learned anything (and don't give me the bs that "I'll study the code and try to understand it", because, no, you won't, you'll simply hand it in and that's it) and for the next assignment you'll be even more lost than you are now.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

man test

[ ] is a "shorthand"/"shell-builtin" for the command test. And, for reference, file-handle 0 is either standard out or standard in. I forget which and it has been years since I've had to worry about it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I agree, but it's not easy for a beginner.

No one said it would be. But the easy way is, often times, not the right way.

Yes, that's right. I don't know how common that would be with default installations.

Quite often considering the number of "unrecognised command" questions I've seen here, and on other forums.

I tested the code with a file on my desktop under XP, where the path includes two spaces. With the extra quotes around the absolute path this does work.

James

So in this instance it did, that doesn't mean it always will. Did you look at what getAbsoluteFilename returns? Does it return the "long" name, or the Progr~1 type name, in this instance?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Parsing a Jar is not hard however. Look at the JarFile class, it's getManifest() method. With that read the Main-Class Attribute, and the Classpath Attribute and build a URL array, and call new URLClassLoader with this array. And, you know, the only real path involved is the path to the jarfile, initially. It is actually quite easy, just need to make sure to cover all the bases, and nothing about the extraneous system changes any little piece of it.

P.S., by paths (in my previous post) I meant the PATH environment variable. If that does not contain the proper path, to the proper bin directory "javaw" (alone without the full path to the command) does not work.

Edit: Also, if there are spaces in that filename (or the path leading to it) be careful. The spaces (due to the way Runtime.exec operates) will cause problems, whether you use quotes or not. Those quotes are evaluated by system shells, and runtime.exec doesn't have one.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No, but PATH defintions are.

Runtime.exec and ProcessBuilder are tools of last resort, IMHO.

And, anytime they are used, it is truely only guaranteed to work on the system on which it was developed as long as no installation parameters have changed. Sorry, that's just the way it is.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Your original approach, using Runtime should work just fine, and has got to be the easiest way to go. What exactly are you passing in as cmd, and what exactly is the error/exception?

Except, of course, that it varies from system to system and installation to installation and so, is only ever certain to work on that system on which it was developed, as long as the installation parameters don't change.

So, yes, should be easy to get working, but oooooo God is it dependable, huh?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, where the heck is kMeansPoint defined? Not in that code.

Also, if you are going to ask on help with an error, post the entire error and give at least some indication of where in the code that error takes place.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, it's not quite as easy as I make it sound, as you also have to read the classpath entries from the manifest file in order to start the URLClassLoader properly, but, if I get time in the next couple of days, I may, and I repeat may write one up for you (as a Generic class for launching other applications).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The classloader is simply so that the executed jar (when you simply call main from the mainclass) has it's own classloader rather than having the classes that it loads, loaded into the rest of the application. Essentially, it is to give it it's own "sandbox", so that you can execute "internally", but still have it "separate" from the application that started it. You can also call main without creating a new classloader (as long as the jarfile is already on the classpath), but then any class loaded from the jar is "visible" to the entire application, which might not be want you want.

Ezzaral commented: Good info. +18
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, if that's your real code, I can believe it's not "sending any errors", as you're ignoring them.

On the other hand, why don't you read the manifest file to get the Main class name, then start a thread, create a classloader, and call the main method from that main class using that classloader, rather than using runtime exec?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yep, this

private void addField(String label, TextField field)
	{
		...
		field = new TextField();
		...
	}

will only create a TextField within the local method, and as soon as the method is done, the TextField is unreachable and will be GCed. And, the textfield, is never associated with the instance field that it should have been associated with. Put your textfields in a hashmap and use a String equivalent to the current field name as the key, if you wish to be able to deal with them in this manner.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The textfields themselves are probably null.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Create a toString method in that HeightStats close to control how it "prints".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And? Have you tried using the -Xlint:unchecked option to javac, yet?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I don't know why you're telling us what you need to do, but I wish you luck.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

convert them all to gif?

With a jpeg image, you can play with "compression level", of course, but this also effects quality. png are not "compressed" at all (as png is gif without the compression routines). So, convert them to gif, and they will get smaller. If you say you can't, then you're stuck.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

*

masijade 1,351 Industrious Poster Team Colleague Featured Poster

That depends on what you mean by "manipulate".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Of course you can declare char arrays, but be aware that each "String" is a char array, so you would need a two dimensional array to hold char arrays equivalent to an array of Strings.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

AFAICT, the <sql:param> tag needs to be nested inside the <sql:query> tag.

Oops. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster
Where id LIKE ?
</sql:query>
<sql:param value="${param.id}"/>
masijade 1,351 Industrious Poster Team Colleague Featured Poster

First of, it is Swing, not Swings.

Second, you probably have not updated the container holding the table. Call validate(), and/or repaint() on the container.

Third, there is no reason to create a whole new table. Create a new TableModel and assign that TableModel to the existing table. Then call validate() and/or repaint() on the JTable.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

P.S. Prefix, not Suffix. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No, that simply removes that one reference from the instance. The instance itself still exists until garbage collected (or not if anything still references it), you just can't get at it.

Calling gc (whether through System or Runtime) does not guarantee that garbage collection will performed as a result of it. It is simply a "suggestion". And, 99.99999% of the time it is completely unnecessary to call gc, as the JVM algorithm is very effecient, and more than capable for 99.99999% of all cases. (Okay, maybe not that high of a percentage, but you get my drift).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because it looks like code that was provided to you with an error that you were to fix. Everyone of those questions that you posted look exactly like a homework question, so much so, that I can guarantee they are.

P.S. I did not insult you, I simply stated my beliefs. If you take offense at someone speaking there mind, maybe you should look into why that is.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

First, use code tags when you post code, I am not even going to attempt to read any of that.

For two, all you've done is block copy your assignment. We are not a homework service, and are not going to do it for you. You even asking is against the terms and conditions that you agreed to when you signed up here.

If that is what you want then go to
http://www.rentacoder.com/

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Of course, but we need more info (as my first reply, sarcastically, implied). Post all error/compiler messages, post your code, and post what the program produces and what it is suppossed to produce.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, using my powers of telepathy and empathy, I will tell you that character 6 on line 225 of your second class should be c.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

1. Periodically. When, exactly, is irrelevant and varies from platform to platform. It is an implementation detail of the VM that the programmer doesn't really need to concern himself with. Also, System.gc(), and Runtime.getRuntime().gc() are only "suggestions" to the the VM that now would be a good time to do GC. The VM does not have to follow it though. It may do it then, it may do it after a delay, or it may ignore it altogether.

2. No. That's "humbug" to quote Ebeneezer Scrooge. There are some cases where it may be helpful, but they are real corner cases (i.e. very, very, very little instances) and, as long as the programmer is doing his job right, should never be a worry.

verruckt24 commented: thats a very good point that every one should be adviced on the use of System.gc() +2