Java Queries Here..

OP
furious_gamer

furious_gamer

Excessive happiness
@gopi_vbboy

You can do it in Java too. Use the URL class to make the connection to the URL, pass the data.
Take the response in a String (StringBuffer) and then parse it.

Exactly what i said.....

gopi_vbboy said:
ok

atleast tell me wat to use to do such web page automation

php or python?

You can do that in Java too, and read the links given by Garbage, if you want to do it in PHP means, you can.
 

SUNANDAN

Right off the assembly line
Check this code out:
Code:
import java.io.*;
 
public class FileOps {
public static void main(String args[])
{
    File file = new File(args[0]);
    try
    {
        BufferedReader in = new BufferedReader(new FileReader(file));
        String s;
        s = in.readLine();
        while(s!=null)
        {
            System.out.println("Read " + s);
            s = in.readLine();
        }
        in.close();
    }
    catch(FileNotFoundException e1)
    {
        System.err.println("File Not Found" + file);
    }
    catch(IOException e2)
    {
        e2.printStackTrace();
    }
}
}
Now I'm getting this error "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at FileOps.main(FileOps.java:13)
Java Result: 1
"
What's the solution? :confused:
create a new func and call it from main,then it will solve.
 

vineetrok

Broken In
I am a newebie in javascript, need some help in the following program!
<html>
<head>
<script type="text/javascript">
function timedText()
{
var i=1000;

for(i=1000;i<=20000;i=i+1000){
var t1=setTimeout("document.getElementById('txt').value = i",i);
}
}
</script>
</head>
<body>
<form>
<input type="button" value="Display timed text!" onClick="timedText()">
<input type="text" id="txt">
</form>
<p>Click on the button above. The input field will tell you when two, four, and six seconds have passed.</p>
</body>
</html>


This is supposed to display time past(in seconds) in a textbox but It's not working.........can someone help??
 

Garbage

God of Mistakes...
Though its not a JavaScript thread, here is the solution.
Code:
<html>
<head>
	<script type="text/javascript">
		function timedText(){
			var i=1000;
			for(i=1000;i<=20000;i=i+1000){
				setTimeout("document.getElementById('txt').value="+i,i);
			}
		}
	</script>
</head>
<body>
	<form>
		<input type="button" value="Display timed text!" onClick="timedText()">
		<input type="text" id="txt">
	</form>
	<p>Click on the button above. The input field will tell you when two, four, and six seconds have passed.</p>
</body>
</html>

Please post the question in right section from next time.
 

A_n_k_i_t

Something Something
I am a newebie in javascript, need some help in the following program!
<html>
<head>
<script type="text/javascript">
function timedText()
{
var i=1000;

for(i=1000;i<=20000;i=i+1000){
var t1=setTimeout("document.getElementById('txt').value = i",i);
}
}
</script>
</head>
<body>
<form>
<input type="button" value="Display timed text!" onClick="timedText()">
<input type="text" id="txt">
</form>
<p>Click on the button above. The input field will tell you when two, four, and six seconds have passed.</p>
</body>
</html>


This is supposed to display time past(in seconds) in a textbox but It's not working.........can someone help??



Here is the modified code

<html>
<head>
<script type="text/javascript">
function timedText()
{
var i;

for(i=1000;i<=20000;i=i+1000){
mytime.txt.value=setTimeout("document.getElementById('txt').value="+i,i);
}
}
</script>
</head>

<body>
<form name="mytime" >
<input type="button" value="Display timed text!" onClick="timedText()">
<input type="text" id="txt">
</form>
<p>Click on the button above. The input field will tell you when two, four, and six seconds have passed.</p>
</body>
</html>

the o/p im getting is 21, 41, 61, when i click...i think there is a logical error in the code. because when i am changing the value of the for loop

for(i=0;i<=20000;i=i+10000)

i am getting odd values...do check it out for that...

If you are a beginner in javascript...
do check out this book its really nice:John Wiley & Sons - JavaScript in 10 Steps or Less

hope this helps....
 
Last edited:

Garbage

God of Mistakes...
the o/p im getting is 21, 41, 61, when i click...i think there is a logical error in the code. because when i am changing the value of the for loop

for(i=0;i<=20000;i=i+10000)

i am getting odd values...do check it out for that...

Thats because the setTimeout() returns the ID, which can be used for clearTimeout() function, and not the value which you want to setup.
Please check the code which I provided in above post.
 

A_n_k_i_t

Something Something
Thats because the setTimeout() returns the ID, which can be used for clearTimeout() function, and not the value which you want to setup.
Please check the code which I provided in above post.


yup, clearTimeout() can be used...but not necessary...ya checked your code...
thanks for the tip...
 
OP
furious_gamer

furious_gamer

Excessive happiness
Javascript doesnt comes under Java. So please stop posting Scripting queries from now on. If you wish, just start a new thread for that and post your questions there.
 

prateek007391

In the zone
Okay, it has been 2 days I have started to Learn JAVA, after having read the book, I found that I need to change the environment variable to run JAVA program In CMD.

However after changing Environment variable i found that my basic CMD commands are not functioning well, then I had to reset the environment variable.

Now I am using NETBEANS to create and run program.
Plzz help what wrong am I doing
 

Bandu

Journeyman
Okay, it has been 2 days I have started to Learn JAVA, after having read the book, I found that I need to change the environment variable to run JAVA program In CMD.

However after changing Environment variable i found that my basic CMD commands are not functioning well, then I had to reset the environment variable.

Now I am using NETBEANS to create and run program.
Plzz help what wrong am I doing

You probably did set PATH=<something something>

Instead do set PATH=%PATH%;<something something>
 

Bandu

Journeyman
No, Not working
After setting it as path, when I try to use cmd commands like
ping xxx.xxx.xxx.xxx
it says
'ping' is not recognized as internal command

There's a small correction. It actually is:

Code:
set PATH = %PATH%;"C:\Program Files\Java\jdk1.6.0_20\bin"

And as far as your ping not working: it maybe because you haven't done this in a new cmd window. Close your current window, do the set PATH thing again in a new window and then try the ping command.

And if still does not work, then tell me the outputs of the following command in a new cmd window, before and after setting the PATH:

Code:
echo %PATH%
 

prateek007391

In the zone
No, Not working
After setting it as path, when I try to use cmd commands like
ping xxx.xxx.xxx.xxx
it says
'ping' is not recognized as internal command


Oh Yes!!!!!!!!!
Finally I figured It Out, Thanks for helping.

Instead of %PATH% I wrote %systemroot%\system32;C:\Program Files\Java\jdk1.6.0_20\bin

and now all is working fine.
 
Top Bottom