I told you to post your code in the appropriate bbcode tags:
public class readTxt
{
public String afile;
public String getFile()
{
return afile;
}
public static void main(String[] arg) throws Exception
{
try {
ConnectToMSSql db = new ConnectToMSSql();
Connection con = db.getConnection();
readTxt rt = new readTxt();
String filename = rt.getFile();
InsertData( con, filename);
con.close();
}
}
public static void InsertData( Connection con, String filename) throws Exception
{
try {
Statement d = con.createStatement();
d.executeUpdate( "insert into SentenceTxt (filename) " + "values ('"+ filename +"')" );
d.close();
}
catch( SQLException exception) {
System.err.println( "Exception handler in ReadSourceFile:InsertData exit(5): " + exception.toString() );
}
}
}
<?php
$filename ="abc";
$obj = new Java("readTxt");
$obj->afile = (String) $filename;
$obj->main();
echo "Test".$obj->getFile();
?>
Your Java class looks malformed since you have a try with no corresponding catch or finally. You need to fix that. (I assume that there are appropriate imports.) Plus, the main method probably should not be declared to throw Exception especially with that try block if you add a handler for Exception.
I speculated on the problem being a failure to pass arguments, but you did nothing to see if changing that would work. Try:
<?php
$filename ="abc";
$obj = new Java("readTxt");
$obj->afile = (String) $filename;
$obj->main(array());
echo "Test" . $obj->getFile();
?>