masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because Generics is acheived through Erasure (google "java generics erasure" to find out more about this).

Simply do List<String>[] a = (List<String>[]) new List[5]; It will give you a warning about an unchecked cast, but it works. You will be able to retreive elements from the array as List<String>'s without having to cast them at that time. I.E. List<String> b = a[0]; , rather than List<String> b = (List<String>) a[0]; . And String s = a[0].get(0); also "works". And, the following will result in compiler errors a[1] = new List<Integer>(); . You just simply can't do new List<String>[] due to the restrictions of erasure.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

By placing the mysql jarfile in the same place as your jarfile and reference both jars in the html using the archive tag/parameter.

See http://java.sun.com/j2se/1.4.2/docs/guide/misc/applet.html for description of the Archive tag (and other applet tags).

And see http://java.sun.com/docs/books/tutorial/deployment/applet/deployingApplet.html for the current way of using applets using JNLP. And, it would probably do you good to read that entire tutorial.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

no, it is objQueue[0] that is null. When you initiate an Object[], each of the elements initially contain null. You still have to define the individual elements of the array.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What do you mean "start at one"? Do you mean that the first index should be 1 and not 0? Well, you can't. Java arrays (and the arrays of most other languages) index starting with 0. Make the array one longer and simply don't use the first index, or use indexes from 1 to array.length and simply subtract one when you actually index into the array.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No, it means you need to define a new run configuration for your project and include that "-D" option in that run configuration! As I already said.

My God, this is exactly why you should not learn Java (or any language) using an IDE. You haven't got the first clue what you are doing. You should learn the language using a simple text editor (with syntax highlighting, maybe) and the command line. Than, at least, you would learn what the command consists of, what the arguments are, both VM and program arguments (which are two different things), and learn what the classpath, library path, and path are (all of which are different things), and learn how to use them.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

See this thread for a concept that may help you

http://forums.sun.com/thread.jspa?threadID=5172164
then see the site referenced there (reproduced here)
http://www.javaregex.com/

Only Perl and PHP have builtin support for this so the only resources I can point you to to help with the concept are pages concerning those languages, such as this one
http://perldoc.perl.org/perlfaq6.html
more specifically
http://perldoc.perl.org/perlfaq6.html#Can-I-use-Perl-regular-expressions-to-match-balanced-text?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

hey it exists otherwise how it can satisfy the if condition.......

Because the if uses rs1 and the get uses rs2.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

i ever try to write without the space but it did not work.i didnt know whether dll file can be set up to java library path using this way.i also ever try to write it without the TBSProxy.dll.below is the manual on how to set TBSProxy.dll from TPM/j API user guide and actually im not really understand what it means.or u can view the full user manual at this link http://projects.csail.mit.edu/tc/tpmj/UsersGuide.html.

hope you can help me to understand it.thanks.

The "command" shown at the end of that quote is only a partial command, showing you what you need to add to the command that you usually use.

You need to create a new run configuration for your project to add that argument to any execution you do from NetBeans (I know it is done from the "Run" menu, but I don't, currently, have a NetBeans in front of me so I cannot describe the process).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

hello all friends i need your help in java.library.path setting.i use a TPM/j API to develop an application using Trusted Platform Module (TPM) specification and to use TPM/j API i need to set java.library.path and load TBSProxy.dll. I try to set java.library.path using DOS and it not works.

C:\Users\lfgs\tpm\tpmj>java -Djava.library.path=C:\Users\lfgs\tpm\tpmj\lib\ TBSProxy.dll

and it return java.lang.NoClassDefFoundError

is there any error in my coding/syntax?

What's with that space after the last "\"? And which class/jar are you attempting to execute?

and then i use netbeans and execute java file with the contents

System.setProperty("java.library.path", "C:\Users\lfgs\tpm\tpmj\lib");
System.loadLibrary("TBSProxy.dll");

and this also didnt work. any java expert please correct me if i've make mistakes in the syntax.my program cannot execute when i fail to load the TBSProxy.dll files

thanks for any help

Well, this can't work. This option must be set from outside the program. This option is available inside the program only for information.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

people seem to think its rather confusing

I have no idea why that would (or even might) be.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Instead of

StringTokenizer Tok = new StringTokenizer(curLine);
        	String compare = Tok.nextToken();
        	    
    	    	if (userInput.equals(compare))

why not just

if (curLine.startsWith(userInput))

or, if there can be whitespace at the front of the line, or the "first token" can be of varying lengths (i.e. the "userInput" might match two different tags due to additional characters) then

if (curLine.matches("^\\s*" + userInput + "\\s+.*$"))

(for performance on this though, you will probably want to do this String concatenation before the while loop and just use it in the while loop).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

remove the "int" and/or "double" now, from the call to the method. You include types when defining and declaring the methods. You include only values when calling the methods.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Looking only at the "Area" class, which is what the assigment text was concerning, it looks just fine (you probably want to make the methods public, however), and give all classes a package. Do not use the "default" package, that will only, eventually, cause heartache and pain.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm, to tell you the truth, the compiler is helping you with that, with the messages it produces when you attempt to compile it. What are they?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm, because a column ("count" + p) doesn't exist, in that ResultSet?

The rest of that exception would be helpful though.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You declare "throws Exception" in the declaration of the method, but when you use the method you are catching "STAFException". If "STAFException" is the exception that might be thrown by your method, then you need to declare "throws STAFException" and not "throws Exception". If you do use "throws Exception" then you need to use catch "Exception" when you use the method.

It's as simple as that. You need to "catch" what you "throw". Exactly what you throw (or more (not less) general). I.E. When you declare to throw IOException, you can catch Exception, but not FileNotFoundException (P.S. FileNotFoundException extends IOException which extends Exception).

Edit: a bit slow.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Return a List<String> maybe?

Or use += instead of =, maybe?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Regardless of the amount of input parameters use PreparedStatement. What if getParameter on USER return ';delete * from FMC_EMPLOYMENT;-- ? Or, more innocently, either one contains a simple "single quote" (')? PreparedStatement will prevent this sort of thing. It is not perfect in preventing SQL injection attacks, but it definately helps.

As far as the errors, then "req" is not defined in this scope.
And you forgot a quote (") at the end of the statement, before the closing paren. (And you forgot a plus (+) between the get parameter and that closing string.)

You need to look at your code more carefully.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm, forget a quote (") before SELECT?

P.S. Use PreparedStatement.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Try this:

Open notepad, add a few lines text, and save that as "C:/bogus.txt" but don't close it.

Then start this program running

package readtest;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import javax.swing.JOptionPane;

public class Main {

    private static void read(BufferedReader br) throws IOException {
        String s = null;
        while ((s = br.readLine()) != null) {
            System.out.println(s);
        }
    }

    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new FileReader("C:/bogus.txt"));
            try {
                int yes = JOptionPane.OK_OPTION;
                while (yes == JOptionPane.OK_OPTION) {
                    read(br);
                    yes = JOptionPane.showConfirmDialog(null, "Continue Reading?");
                }
            } finally {
                try { br.close(); } catch (Exception e) {}
            }
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
}

when the confirm prompt comes, enter a few more lines txt and save (but don't close although you can, it is simply easier to keep it open), then press yes/ok on the confirm.

Repeat as often as you like. When finished press no/cancel on the confirm.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Place the read routine in a separate method (if not a separate thread, as well) and don't close the reader just because EOF is encountered. Once you need to read more from the file, simply call the read method again. If more data exists in the file, at that point, it should start reading again, from the point where it left off last time.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I would guess you have an extra '}' before the line containing the first error.

Also, that first error takes place on line 18803? You really need to break that thing down. You shouldn't even be attempting to do everything in one class.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And all completely unnecessary.

Netbeans creates a jarfile, it is in the dist directory.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

P.S. "double clicking" works to (which is what most "people" who ask this question are actually concerned with) by creating a jarfile, see the deployment tutorials.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And no, you cannot run a compiled "exe" anywhere. You can run it anywhere that has the exact same OS and architecture as the machine it was compiled for. That is exactly what Java does (except that they also work with newer versions), except that the "OS and machine" for which it is compiled is the JVM. So, you can run it anywhere where there a JVM present of, at least, the same level for which it was compiled.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Try using the GridBagLayout colWeights and rowWeights arrays, rather than assigning per item. I haven't lloked closely, but I already see a weighty of 1.0 on row 0 and 1 and a 0.1 on row 2, that means you are attemtping to use 210% of the space. Just because you are giving those values to a single component, they apply to the entire row, not just the component. That means it is easier, less error-prone, and more effective to simply set weightx and y to 0.0 and use the Layout's arrays. Try that first (as shown in the example).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Study this

package test;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class BogusGridTest {

	private static void doIt() {
		JFrame.setDefaultLookAndFeelDecorated(false);

		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		JMenuBar mb = new JMenuBar();
		mb.add(new JMenu("File"));
		frame.setJMenuBar(mb);

		GridBagLayout gbl = new GridBagLayout();
		GridBagConstraints gbc = new GridBagConstraints();
		frame.getContentPane().setLayout(gbl);

		gbl.columnWeights = new double[] { 0.7, 0.3 };
		gbl.rowWeights = new double[] { 0.1, 0.7, 0.2 };

		gbc.anchor = GridBagConstraints.CENTER;
		gbc.fill = GridBagConstraints.BOTH;
		gbc.gridheight = 1;
		gbc.gridwidth = 1;
		gbc.insets = new Insets(1, 1, 1, 1);
		gbc.ipadx = 0;
		gbc.ipady = 0;
		gbc.weightx = 0.0;
		gbc.weighty = 0.0;

		JPanel incScrollPane = new JPanel();
		incScrollPane.setBackground(Color.WHITE);
		gbc.gridx = 0;
		gbc.gridy = 0;
		gbc.gridheight = 2;
		gbl.setConstraints(incScrollPane, gbc);
		frame.getContentPane().add(incScrollPane);

		JPanel usrLabel = new JPanel();
		usrLabel.setBackground(Color.GREEN);
		gbc.gridx = 1;
		gbc.gridy = 0;
		gbc.gridheight = 1;
		gbc.gridwidth = GridBagConstraints.REMAINDER;
		gbl.setConstraints(usrLabel, gbc);
		frame.getContentPane().add(usrLabel);

		JPanel usrScrollPane = new JPanel();
		usrScrollPane.setBackground(Color.YELLOW);
		gbc.gridx = 1;
		gbc.gridy = 1;
		gbl.setConstraints(usrScrollPane, gbc);
		frame.getContentPane().add(usrScrollPane);

		JPanel senScrollPane = new JPanel();
		senScrollPane.setBackground(Color.CYAN);
		gbc.gridx = 0;
		gbc.gridy = 2;
		gbc.gridheight = GridBagConstraints.REMAINDER;
		gbl.setConstraints(senScrollPane, gbc);
		frame.getContentPane().add(senScrollPane);

		frame.setSize(400, 200);
		frame.setPreferredSize(new Dimension(400,200));
		frame.pack();
		frame.setVisible(true);
	}

	public static void main(String[] args) {
		SwingUtilities.invokeLater(
				new Runnable() {
					public void run() {
						doIt();
					}
				}
			);
	}
}
masijade 1,351 Industrious Poster Team Colleague Featured Poster

You have used only weightx and not weighty and you have only used a horizontal fill, so your elements will not even attempt to fill the space vertically, and all "unused" space in the container will dispersed evenly around the components (i.e. the "free" vertical space will be half above and half below the components and the "free" horizontal space will be half to the left and half to the right of the components).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Nice statement, but no pattern and no code.

We are not here to write your code for you, but will me more than happy to help you correct yours, as soon as you post it, the pattern, and a specific question.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You can delete the old versions. The worst that may happen is that some program still wants to use an old one, at which time you can alter it's configuration to use a newer one (although, in some cases, that may mean making registry changes on your own). This is fairly rare, however, as the installation usually takes care of this.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Not with a CGI of any kind. JavaScript, maybe.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Maybe I'll come back to this later. I knew it was going to be this kind of question and I am just not in the mood right now.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Use an ArrayList rather than an array, and you don't have to worry about all that array manipulation. And as far as "storing" the data, how do you propose to do that with an empty actionPerformed method?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Try calling validate (and or pack) on the frame before calling setVisible (and then, you probably shouldn't have to call repaint).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because, since you are simply painting to the graphics in an external method, rather than overriding the paintComponent method in JPanel will cause the standard "painting" of the panel to erase it. Either extend JPanel and override the paintComponent method, or have that method create an image (use BufferedImage and you can do that exactly as you are doing this now) and set that as the contents of the JPanel.

aym312 commented: insightful and truly helpful +0
masijade 1,351 Industrious Poster Team Colleague Featured Poster

No, the cgi script does not execute "in the browser". A CGI script runs on the server, and that is where the "application" is opening. A CGI script produces HTML (or whatever other output it is designed to produce, such as XML, etc) and that is what the browser gets. Any thing else, happens on the server.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

That "class" however, is not doing any SQL. You need to provide the DataHolder class. Also, currently you are doing your work on the event thread which is more than just wrong. You need to learn about MVC and use it. At the very least, you need to completely separate your DB and GUI code and do the actual DB work in a separate thread that then triggers an update of the GUI.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
String queryLNLike = "SELECT * FROM employees WHERE firstName LIKE in(?)"+
"'" +ln+ "%" + "'";

Like In?

I don't think that could ever work.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What is "g1" (hint, you can find it two lines higher in the code)?

Edit: And then read reply #7 again.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well look at the code. What do think this " g1.drawString(output, 10, 20);//10, 20 keeps it neat in corner. " is doing?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Please stop opening duplicate threads. Post your code into this thread.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

By calling repaint on the canvas after modifying the graphics object?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay? And if your first array is only 3 elements long (which is what you use to create the second array so it is also only 3 elements long, i.e. last index of 2) and one of the Strings is 6 characters long, what happens?

If you want to do it this way, then you need to find the longest String first, and make your second array that length (that length + 1 actually, since arrays are 0 based).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because you're trying index into an array using an index value representing the length of one the Strings stored in the array. What did you hope to achieve by doing that?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

All of which, of course, has nothing to do with either ASP nor PHP, so what is the deal with your title?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Ok, so I've read through this and I don't see anywhere in the blog consideration of the error message you're getting.

Then re-read the first reply.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Google "Java OCR", maybe? (P.S. OCR is Optical Character Recognition)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No, not easily (at least not if they are to change during the running of the app). If they are values being delivered, that should never change, then no problem. You would be wise to look into the Preferences API, however.