masijade 1,351 Industrious Poster Team Colleague Featured Poster

In short, you can't. JSP's and Servlets run on the server and the clients (if they are at all interested in safety/security won't give those resources free to the world). Produce a "print" page for the browser and let the client push "print".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The same way you're reading the doubles, but without the parsing, of course.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

First is "SETUPS" equal to the length of the arrays, or to the last index (which is one less than the length, of course), or some other number, like the index of the second to last element.

If it is equal to the length, than every one of those returns should throw an ArrayIndexOutOfBoundsException.

If equals to the last index, then the second return will throw an ArrayIndexOutOfBoundsException.

If equal to the second to last element (or a smaller index) than none will throw that.

Also, do you really want to return the element at "SETUPS" index every time? Somehow I don't think so.

Also, you can avoid that "MAKE COMPILER HAPPY" BS by doing the following (and I am assuming you don't want to always return the last element, and I am assuming that "SETUPS" is actually the length of the arrays, and not the last index):

public Component getComponentAfter(Container focusCycleRoot, Component aComponent) {
    Component retComponent = aComponent;  // Original by default
    for (int i=0; i < SETUPS; i++) {
        if (aComponent == bsTextFields[i]) {
            retComponent = fsTextFields[i];
            break;
        } else if (aComponent == fsTextFields[i]) {
            if ((i + 1) == SETUPS) {
                retComponent = descripTextFields[0];
            } else {
                retComponent = descripTextFields[i+1];
            }
            break;
        } else if (aComponent == descripTextFields[i]) {    
            retComponent = bsTextFields[i];
            break;
        }
    }
    return retComponent;
}

Fixed a few other assumed errors, as well. And I don't usually "give out" code as I find it, usually, counter-productive to the receivers learning.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I agree. Like I said, usually. ;)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

A Frame is meant to encapsulate an application. Something that is only temporarily open, and especially when it is a part of the same application as the previous frame, it should, more correctly, be a Dialog. A JDialog can contain anything a Frame can, so you don't lose anything. The only thing it doesn't have is the minimise/maximise buttons. And, you also don't need to "be careful" about what default close operation you give, since you don't give it any. But you can still assign a WindowListener to it, in case you do want to do something specific when it closes.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

P.S. Two full-fledged Frames in an application is usually a mistake. Especially when one is opened as a result from the other. Usually that "second" Frame should be a Dialog (i.e. extend JDialog rather than JFrame in the "second" Class).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I'm sure it has documentation.

Ezzaral commented: What a crazy suggestion! +23
masijade 1,351 Industrious Poster Team Colleague Featured Poster

hello, im a beginner programmer in java (J2ME),

is there a way on how to unobfuscate a java?

Try to guess what the variables, classes, methods, and packages should be named? IOW, no, AFAIK.


and how to obfuscate it?? (J2ME)

With a third party tool. Google one.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, to "scale" the image, you would first have to have it loaded.

The only other way is to know the structure of the image file, and the original size and density parameters of the image (which can also, usually, be obtained somewhere in the file), so that you can read the file, a part at a time, restructuring/scaling as you go and write that, a part at a time, into a new file, which you could then load as an image.

This, of course, takes intimate knowledge of the storage structure of the image format in question, of course.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Then the image is simply too big. You need to modify the image before attempting to load it into your app.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

How big is that image?

You need to increase your heap size. The -Xmx=### is the command line option.

See http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html

masijade 1,351 Industrious Poster Team Colleague Featured Poster

i also try not to invent one by myself..

This is what you are supposed to do.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Have you looked at the API of the String class?

Actually, I believe he's talking about the classic homework assignment of changing "1" to "one", "2" to "two", and so on and so forth. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Maybe because your homework assignment is to write one and not to copy/steal one.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

grep will only match the lines (and return the entire line, not just the matched portions of it), and will not alter them. If you wish to alter the lines you are going to need to use sed, or something similar.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

PreparedStatement and setDate and setTimestamp

http://java.sun.com/docs/books/tutorial/jdbc/index.html

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I can't speak to its quality, but there's this one

http://www.java2s.com/Tutorial/Java/0340__Database/DatabaseMetadata.htm

All I can say is to google "databasemetadata resultmetadata tutorial", but steer clear of anything from roseindia.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm, sorry, but both DatabaseMetaData (before executing a select), and ResultSetMetaData (after executing a select) can both give you this information in a much, much, much more db independent way.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because of this statement

package helloworldapp;
..
..

you have to change the your method of compilation and also execution.

If package is mentioned then your .class must be placed under the package named folder.

No it doesn't. It is convention to do it that way, but you don't have to. You could place every one of your Java files in the same folder, or all of them in wildly scattered directories around the system, you would have a hard time compiling all of them at the same time, you'd probably have to compile one at a time, in the proper order, using the "-d" option, but you could do it, if you really wanted to.

Now, compile your program
>javac HelloWorldApp.java -d .

>java helloworldapp.HelloWorldApp

Note:
>javac HelloWorldApp.java -d .
where, -d option create a package folder and
. means current folder
>java helloworldapp.HelloWorldApp

"-d" does not mean create a package folder, and using "-d ." is absolutely meaningless, as that is the default anyway. The "-d" option is so that the compiled class files do not appear "in place", but rather somewhere else. I.E. You have a folder containing a src folder and a bin folder, you cd to the source folder and then use "-d /path/to/bin" to have the compiled class files appear (with a full package directory structure) under bin, rather than in place under src. Don't forget, however, to include "-cp /path/to/bin" on the javac commands, however.


…

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Also, although the API docs for java.sql.Date state that the time will be rounded, in my experience, it has always only done that when formatting a String representation of the Date, and that the actual Date object still retains the entire Date value. Try the following and see if that is not the case

public class UtilSqlDateTester {
	public static void main(String[] args) {
		java.util.Date d = new java.util.Date();
		System.out.println(d);
		java.sql.Date s = new java.sql.Date(d.getTime());
		System.out.println(s);
		java.util.Date sd = new java.util.Date(s.getTime());
		System.out.println(sd);
	}
}
javaAddict commented: OK +7
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Actually if you use the getDate(), it will return a java.sql.Date, which doesn't hold the milliseconds.
When I want to get date from database I usually do this at the query:

TO_CHAR('format', date_column);

And then use the ResultSet.getString() method

Then use getTimestamp if some part of the Date is really getting cut using getDate.

Edit: IOW, without an extremely good reason, retreive the proper type for the column involved. There should, in 99.999999% of all cases, be no reason to have to play with these conversions when retreiving info from a DB.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, looking at the API docs the last example is

"yyyy-MM-dd'T'HH:mm:ss.SSSZ"  	"2001-07-04T12:08:56.235-0700"

This seems to be extremely close to what you need.

String value = "2009-05-20T18:19:23+08:00";
value = value.replaceFirst(":(\\d\\d)\\s*$", "$1");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
Date date = sdf.parse(value);

Also, is this "String" being read from a "Date" column out of the DB? If so, why are you using getString to read it rather than getDate?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read the API docs for SimpleDateFormat.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

This

private Map<Integer, Integer> targetMap;

declares it, but doesn't define it, which is fine, at this point.

This

Map<Integer, Integer> targetMap = new TreeMap<Integer, Integer>();

declares and defines a new Map, local to the method that hides the instance variable.

So, either remove

Map<Integer, Integer> targetMap = new TreeMap<Integer, Integer>();

and add

targetMap = new TreeMap<Integer, Integer>();

to the constructor.

Or Change

Map<Integer, Integer> targetMap = new TreeMap<Integer, Integer>();

to

if (targetMap == null) {
    targetMap = new TreeMap<Integer, Integer>();
}

but then, don't forget to check whether targetMap is null in the other methods before attempting to use it, or you may still throw a NullPointerException in one of those areas.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I assume you want to "put" the values here, but "get" the values in another method, right?

Well, you're declaring the map in this method, so as soon as this method is finished the map goes out of scope (i.e. doesn't exist anymore).

You need to either declare the map as an instance variable, or pass it into the method, rather than declaring it here.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Student is a class, that method is meant to be called using an instance, and not a class, reference. So, either create an instance of Student and call the method using that, or declare the method static.

Either way will work, since that method is not using any instance data, itself.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Sorry, but how does doing someone (home)work for them help?

Sure, they can blindly turn in this assignment, but what about tomorrow? When the lesson they are going to be taught is meant to build on what they learned today. Well, they didn't learn anything today, so tomorrow is twice as hard.

P.S. Not that I even bothered to look at the code though, so don't think I'm approving the way you did it, either.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Also, are you to return the number of bytes, or the number of charatcers? If this is a UTF character stream, those two will be two different things.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

If your talking about how you declared the int and incremented it, then yes, if your talking about passing in byte arrays and creating inputstreams, then, well, why do you think I told you to start over at the beginning of the thread?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

In your inital post, you were to take an intpustream as the argument and count the number of bytes in it. Now you're talking a byte array? Well, if in that case the purpose is to return the number of bytes in the byte array smply return b.length.

Somehow or another, you seem to keep slipping sideways whenever you "correct" something, rather than coming closer to your goal.

Go back to the very start of this thread, and the code that was posted there, then, go through the first few posts changing only those parts of that code that you were told you needed to change and you will have your solution as of post #6.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Every public class must be in a file of the same name. You cannot declare two public classes in the same java file.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I have now given you a full answer on Sun's forums.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Do you want to match the String "wati", or do you want to match a String that contains a w or an a or a t or an i (which is what your pattern says now)? Or do you want to match a String that contains all of those characters regardless of order or amount?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

return the list.

public List<Customer2> whatever() {
    List<Customer2> list = new ArrayList<Customer2>();
    ....
    return list;
}
masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Sorry, but his question started

create a method where it takes a InputStream as a parameter

and not, necessarily, anything to do with a file.

If you want the size of a file, simply use the length() method.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Do you know how to declare an int variable?

Do you know how to increment it?

Well, declare one before the while loop, and increment it within the while loop. And, do nothing else inside the while loop.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I thought you wanted to count the bytes, not write them out to something else (and, actually, you're trying to write it out to the inputstream you're currently reading, don't you see something wrong with that?). That should be where you look. Don't you think you should be incrementing a variable there, instead?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Question 1.
Some class has to have a main, unless it's an Applet, Midlet, Portlet, Servlet, etc.

Question 2.
By having one class reference the other.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Anywhere you want to as long as it is not declared inside another method/constructor/block.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
yourFrame.setContentPane(yourPanel);
yourFrame.repaint();

Or, read the API docs for CardLayout.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Of course not. The first reply is a link to a place where you can hire someone to do it for you, if that is what you want. No one here is going to do it for you.

The second reply contains a link to a good Orcale forum where you can ask about the SQL to be used, and a link to the JDBC Tutorial, so you can learn how to create and use DB connections.

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

http://java.sun.com/javase/6/docs/technotes/guides/security/index.html

Don't be "quick" be "complete", especially with anything that has to do with security.

Salem commented: Wise words indeed. +30
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, hopefully, the both of you are at least competent enough to comment and document it. By doing that you might just get some sort of inkling of what was done. Don't really know if I'd count on it though.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You start with a text editor.

Now, do you have an actual question? Or are you just looking for someone to do this for you?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Unless you want to do an applet, you need to learn AJAX (or something similar) first.

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

Look a bit closer at the varying "exec" methods. One of them allows you to pass environment settings (read variables). The "exec" does not have a full environment, it is not a real shell. You need to pass the oracle_home, etc, variables to it's "shell" using the form of "exec" that allows you to do this.