masijade 1,351 Industrious Poster Team Colleague Featured Poster

So, you have a homework assignment due on Saturday, and download code out of the Internet on Thursday (that you don't understand), and expect us to finish it for you. Well, well, what will have you done to earn your grade, then?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Closing this zombie now.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

As long as there are no "quoted" fields in the csv, then simply read it line by line (using a BufferedReader wrapped around a FileReader and BufferedReaders readLine method) and use split to split the line to a String[] and take index 3.

Edit: Also, if you don't need to retain the file, then use a BufferedReader, wrapped around an InputStreamReader, wrapped around the inputStream from the HttpURLConnection and parse it directly from the web.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No idea what you want. In any case, there is only one int type in Java, 4 bytes signed. If you want more, use long or BigInteger, if you want less use short.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm, the one provided by netbeans? Visit their website.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

"Study how one is built" or "turn it in as my homework"?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Even at the pseudocode level that's not going to work:
firstStep = console.nextLine(); eg "ooxxx"
secondStep = firstStep.replaceAll(o, x); "xxxxx"
thirdStep = thirdStep.replace(x, o); "ooooo"
System.out.println(thirdStep); "ooooo"

This needs an extra step:
replace all the o with some temp char
replace all the x with o
replace all the temp char with x

Too slow! ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Actually, that won't work, anyway. As if you replace all o with x then all x with o your string will consist of nothing but o

Step 1: get string
Step 2: replace x with z
Step 3: replace o with x
Step 4: replace z with o

Why do you feel the need to do it in one?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well start out by defining a class and within that class defining the two methods described above, as a start. Then, in the main method, ask for input and convert it using those methods.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, I believe I said in the first reply that we weren't going to do it for you.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay? And the rest of the methods?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Thanks for what?

We are definately not going to do it for you, especially when you can't even take the time to describe your problem.

Show your code, provide a good, but short, description of the current problems with it, and provide any and all error/compiler messages and we may help you solve it (although I don't know about that after this pitiful plea).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

So parse those "results" to retreive those urls and Desktop.browse() to "open" them in browsers.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

A submit button will forward to the page listed in the form tag, of course. What you need is some java script to add on a query parameter to that url and a "central" site that forwards the request to the proper page based on that parameter.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

1. and 3. Connection Pools, see the documentation for the web container you'll be using.

2. A class that provides the user interface and an interface (java interface) and every "object" that should be searchable should implement this interface.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

HttpURLConnection and an HTMLParser ?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I give up.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Where did you do that? If in .bash_profile, is .bash_profile even being used? Or is it using .bashrc?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

That line is creating the classpath variable. It doesn't matter if one already exists or not.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You don't want to use CLASSPATH anyway. If you insist, however (and they always do), simply add that line directly to the .bash_profile (if that's even used otherwise .bashrc) environment file.

Edit: If, however, you insist (and they always do) on keeping it in a separate script, then you need to source that script from the proper environment file, not just execute it i.e.

. script.sh

not just

script.sh
masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm, I wouldn't use read(), use the byte[] version of the read method (properly), as you are liable to find that version you're using to be extremely slow.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yep, you can't control that (AFAIK), unless IE has some option, but that's a Microsoft question. As I said, use HttpURLConnection and JFileChooser, Google for some tutorials.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, how are you "doing" the download?

I would assume you would use a HttpURLConnection and a JFileChooser, but it seems you are using Desktop.open(), no?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

If you are the site from which something is being downloaded, you can't, that's a browser setting. Otherwise, how are you opening the "file download box of internet explorer".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

That, then, would be a MySQL question (they write the JDBC Driver). But if you use the IP address and the server gets the hostname (as that message implies) and it cannot, or is unable, to resolve that name to the "proper" ip, then, of course, your grant won't work.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because you included the "codebase" parameter in the second. If you do that you are going to need another "sourceCode" directory under that "sourceCode" directory.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Ask microsoft/MySQL? In any case, not a Java question.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read the user management portion of the MySQL documentation and pay close attention to the "GRANTS" portion of it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Not without knowing what you've done. Create a small, self-contained, compilable, and executable example that recreates the problem and post that here.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm, nextInt(), etc, do not "consume" the newline that follows it, so if you use "nextLine" after using something like nextInt() you will get whatever there was between the type retrieved and the next newline (usually nothing if all you expected was a single type on that line). So, if you are expected a single type on a line (and you insist on using Scanner for this) then call nextInt (or whatever) and follow it immediately with nextLine (again, assuming you are only expecting a single input on a single line, otherwise call it after retreiving the last expected type).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Use a Panel with FlowLayout on that "Card" of the CardLayout?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm, three overloaded methods with <T extends ComputerPart>, <T extends Peripheral>, and <T extends Service>?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Dear All,
I have a java application which link to db on another computer on the local lan. The problem I have install jdk_1.6_21 without any problem. Then I have paste mysql-connector-java-5.1.14-bin.jar in /usr/java/jdk1.6.0_21/jre/lib/ext. When I compile my program has no problem when I try to run I get this error java.sql.SQLException: No driver found. I have been doing this method all this while it works suddenly this new machine have this problem. Any help please.My Os is centos 5.5.

Are you maybe ignoring the exception when you load the driver (or are you using the inherent "Service" capabilites as of Java 6/JDBC 4 (is the current version 4 or 5?))? Or have you mangled the connection url? As that error is not caused by a missing driver, but rather by the attempt to use a driver that has not been loaded (or a mangled connection url so that JDBC doesn't know what driver it should be using which amounts to the same thing).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It souldn't have problems with it (unless, of course, you are using the "null" layout or something).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay? And your problem is?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Hello to all.

I have build a Java GUI application and now i want to convert and transfer it to an applet.

I assume that whatever i have in

public void main

will now go to the init() method of the JApplet.

Not necessarily. It would probably be a good idea to put some of it into init and some of it into start, and possibly, some of it into stop, as well as defining additional "behaviour" for the start and stop methods.

Now the problem is to embed it to the webpage...

I have this code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="_css/style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<applet code="Applet1.class" width="400" height="300">
    
</<applet>
</body>
</html>

the index.html and Applet1.class are in the same directory but when i am trying to run the applet is loading and then its says


I got this error report

java.lang.NoClassDefFoundError: Applet1 (wrong name: sourceCode/Applet1)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(Unknown Source)
	at java.lang.ClassLoader.defineClass(Unknown Source)
	at java.security.SecureClassLoader.defineClass(Unknown Source)
	at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
	at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
	at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
	at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Exception: java.lang.NoClassDefFoundError: Applet1 (wrong name: sourceCode/Applet1)

I suppose the problem is here?

Applet1 (wrong name: sourceCode/Applet1)

where sourceCode is the package that i have declared in Eclipse???

When i run the Applet in Eclipse everything is ok, when i try to run it in browers i …

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes. A good rule of thumb, I've found, is that public (and maybe protected) methods should use the interface (I.E. list) as parameter and return types. Whereas private (and maybe default) methods could easily use the implementation (I.E. ArrayList). This second part can make changes more widespread when a change is made, but it does not change the public interface and so those changes could still be made without affecting (theoretically) anybody else's code that may be using your API. Also, local variables should always use the implementation (if there is any chance you'll be using, or relying upon, functionality/behaviour that the implementation guaranties that the interface does not). They declare more functionalities than the Interface does, and there is no reason to restrict yourself in a local scope.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

By using a WindowListener, an ActionListener, and an ItemListener.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Create a String constant "*********************************************"
then use substring(0,numAster) to pick the right numbert of *s from the fromt of it.

Uhm, a loop would still be needed, though. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What about Python inspired iteration?

byte range[] = new byte[5];
for (byte nul : range) {
    System.out.println("do stuff");
}

Uhm, you do realise that that is still a for loop, right? (In your code anyway, what actually gets compiled is an Iterator with a while loop.)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Whatever. You need to wait on the process before trying to get the exit value. Google for a tutorial and read the API docs. You're still going about it all the wrong way, regardless. What is the reason for the opposition to libraries? Have you asked for any reasoning on that? Or is it just a clueless individual? Did you even ask? Didi you even attempt to convince them of the folly of that decision? Or did you just make that up so you could push your "solution"?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

However, I would ask why this needs to done in Java? If you already have a script that downloads the file, could not that same script simply call a DB utility to "load" it?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Why not "write the download" in Java? How is it being downloaded? If by FTP google for an FTP library (apache provides one), if by http, see the API docs for HttpURLConnection, if by SSH see JSch.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The "connection object coming to it" is the one provided to it by whatever calls it. What calls it? Where did that get its connection? I assume you do know what your program does, right?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Sure, reverse engineer/decompile them, then right a "controlling" wrapper program, and recompile them into a single program.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Closing this meaningless zombie now.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

With an object to "record" the coordinates of the line and then either drawing, or drawing over, the line on button click using an actionlistner and swingutilities.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You won't find any "good tutorials on web crawlers". That is a bit of a broad subject. Find some tutorials on HTML parsers and HttpUrlConnection as well as some good general explanations of what a web crawler consists of and go from there.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Open a text editor, type code, save, exit the editor, open a command shell, cd to where you saved the code (with a .java extension and the same name as the public class contained) use javac to compile, and java (or javaw) to execute.