Ajit Deshpande2

Greenhorn
+ Follow
since Nov 27, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Ajit Deshpande2

Hi Peter and Avi,
Thanks a lot for your tips. It worked just fine! Thanks Avi for the article link. It's pretty interesting!
Ajit
21 years ago
I am trying to run a simple DOS command from a Java program through the Runtime class. For some reason my program keeps throwing exception. Can someone explain, why I can't run the program correctly?
Here's the code:
import java.io.*;
import java.util.*;
public class Some
{
public static void main(String[] args)
{
Some s = new Some();
Process p = null;
Runtime r = null;
StringBuffer commandOutput = new StringBuffer();
try
{
p = Runtime.getRuntime().exec("dir");
InputStream in = p.getInputStream();
int c;
while ((c = in.read()) != -1)
{
commandOutput.append((char) c);
}
}
catch (IOException ioe)
{
System.out.println(ioe.getMessage());
ioe.printStackTrace();
}
System.out.println(commandOutput.toString());
}
}
This program keeps throwing an exception at the point where I try to make a Runtime class.This is the stacktrace:
CreateProcess: dir error=2
java.io.IOException: CreateProcess: dir error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Win32Process.java:63)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:550)
at java.lang.Runtime.exec(Runtime.java:416)
at java.lang.Runtime.exec(Runtime.java:358)
at java.lang.Runtime.exec(Runtime.java:322)
at Some.main(Some.java:13)
Can anyone explain why this happens.
21 years ago
I have a problem setting classpath. I have set up the basic java compiler correctly. I have a problem whenever I have to add jar files like XML parsers, etc. These add-ons have a number of jar files. Do I have to add extra jar files to the classpath variable? THis makes the classpath too big and unmanageable. Is there a way to just drop the jar files, and the automatically come in the classpath?
22 years ago
Hi Fellas,
I am a newbie with Weblogic just trying to get my feet wet with Weblogic 6.1. I was trying to get to administrative console and it prompts me for a username and a password. Although, I know my password ,I am not sure what username I should use when I am loggin in for the first time? I there a default for the username ( I tried "guest","administrator") ? ANy help will be appreciated
22 years ago
1)
public class A{
public static void main(String[] args){
int i= 2 + '2';
System.out.println(i);
}
}
gives an ouput of 52. How is that? Can anyone explain?

------------------
Hi Lucy,
The wait() is declared as final...hence cannot be overridden. The wait() is present in the Object class which is the parent of all classes in java.
Hope that helps
class Q2a {
public static int amethod(int i) {
i = 10;
}
}
class Q2b extends Q2a {
void amethod(int i,char c) {
i=10;
c='f';
}
}
public class Q2c {
static int i;
public static void main(String args[]) {
Q2b q = new Q2b();
q.amethod(i);
System.out.println(i);
}
}
In the code given above: the output is 0. I thought it would be 10...but its not!! Can anyone explain this output?
HI Gautam, Vidya and Shubhangi....
I have things much clearer now...Gautam your explanation was perfect...also thanx Vidya and Shubhangi to add more on the topic...
Ajit
Hi All,
I had a question from Strings that appeared in SHE mock exam:
Given a string s, constructed by calling s = new String("xyzzy"), which of the calls listed below modify the string represented by s? (Choose all that apply.)
a.) s.append("aaa");
b.) s.trim();
c.) s.replace('z', 'a');
d.) s.concat();
e.) s.substring('3')
-------------------------------------
Correct answer was given as: None
Explanation: Strings are immutable
If the Strings are immutable, why are the methods in the Strings class provided in the first place? Can anyone explain?