babu sharath

Ranch Hand
+ Follow
since Jul 06, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by babu sharath

What is cmd.exe in the code
I am running in UNIX environment
When I run the code I am getting following error :

java.io.IOException: cmd.exe: not found
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:52)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:428)
at java.lang.Runtime.exec(Runtime.java:364)
at java.lang.Runtime.exec(Runtime.java:326)
at Sample.getEnv(Sample.java:19)
at Sample.main(Sample.java:10)
11 years ago
due to some reasons I dont want to use -D option
If I have 10 enviromnet variables , than everytime -D with 1- those variables is not a good option i think
11 years ago
HI ,

I created a environment variable using:
setenv file_name /home/test/a.txt
How to access that environment variable from java code.
I tried
String s = System.getenv("file_name");
I am getting following error when runnig :

Exception in thread "main" java.lang.Error: getenv no longer supported, use properties and -D instead: input
at java.lang.System.getenv(System.java:691)
at Li.main(Li.java:6)

Than I tried
String s = System.getProperty("file_name"); It is giving null as output

How to access the environment vatiable ?
11 years ago
Hi ,
I am using java1.4
I write following code.
Problem is : In the end new file is created , but it is empty nothing is written
in that file . Why ? line1 and line2 should be placed in the file , why it is not happening ?

import java.io.*;
class Test
{
public static void main(String args[])
{
try {
File f = new File("test12.txt");
if(!f.exists())
f.createNewFile();
FileWriter fw = new FileWriter(f);
PrintWriter pw = new PrintWriter(fw);
pw.println("line1");
pw.println("line2");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
HI ,
Sorry I didn't wrote the complete code earlier :

File file = new File("test_file");
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
while( (line=br.readLine()) != null )
{
line = line.trim();
System.out.println( line );
if (line.charAt(0)=='#')
{
continue;
}
}
( When a line starts with a # I want to ignore that )
In above senario , file is read upto empty line and next lines were not read
what is the problem with above code ?

Sharath
HI ,
I want to read the file and print the contents of file.
For that I wrote :

File file = new File("test_file");
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
while( (line=br.readLine()) != null )
{
line = line.trim();
System.out.println( line );
}

Above is working if there is no blank lines in the file.
If file is like below :
test1
test2

test3
End of file.

Then it is printing first two lines only.Because 3rd line is empty.
How to handle this situation ? Is readLine() takes that empty line as null ?

Regards,
Sharath
Hi ,
Thanks .. Now it is working ..
Earlier web-app tag was ...
<web-app xmlns="http://java.sun.com/ns/j2ee"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version=" 2.4">
Now I changed to what it is mentioned in the post.
It is working now ....

Regards,
Sharath
Hi ,
In servlet I wrote request.setAttribute("test",somestringarray );
In JSP I used EL to retrive that array contents like
${test}
But in output those array contents are not coming .. in out put
${test} is coming ...

Do I have to write anything to enable EL

Regards,
Sharath
Hi ,

we have many books in market like HFSJ and others , how do you think that
your book is better than those ? what are the features ??

Regards,
Sharath
ONE MORE QUESTION : do i need to do anything after passing the exam , like filling any form on net ?
I passed the exam on Aug 3, 2006. I haven't got the certificate yet. In cert manager it says kit was mailed 2 weeks back. How long does it take to reach here? I'm in mangalore, India.

in certmanager where did I get the message that it was mailed already .
after logging into certmanager i am unable to find that info .
PLEASE HELP ME REGARDING THIS
where is mailing status there .. i didn't find mailing status any where ..
it is working fine ( /manager/html)
xml file i written is :
<web-app xmlns="http://java.sun.com/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<servlet>
<servlet-name> select </servlet-name>
<servlet-class>com.example.web.Status </servlet-class>
</servlet>

<servlet-mapping>
<servlet-name> select </servlet-name>
<url-pattern> /Selectname.do </url-pattern>
<servlet-mapping>

</web-app>