[hotjoe.com] HotJoe Java Help Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Visit java.com
Missing post? - see this post about spam for more information.
Messages posted by: sara12345
Forum Index » Profile for sara12345 » Messages posted by sara12345
Author Message
ok enshallah it will work but for window preferences do you mean control panel??? because I cann't find preferences??
ok before doing any thing I want to make sure that you understand my problem
I want to call whole c program from java code. the c program takes input file name from command line and it returns output file
I want to call this c code from java
I want to make sure that your method works for my situation. I don't want to user other os. I'm using windows os.
please tell me if this is what you have understand or not?? by the way where can I find the preferences folder in vista
I'm using Eclipse to run java program??
do I have to use something else??
I'm sorry I don't have alot of knowlege about java
I don't know if this may help
also it said in the error message
annotiations are only available if source level is 5.0
I don't know what do you mean by development structure. I have the same directory structure
the path of the file is /Final_project/src/final_project/Minimization.java
and I have run it using run button in java
how can I fix these errors
my java version is "1.6.0_17"
also there are errors at these lines:
callable<Ineger>....
Future<Integer>.....
the errors said that:
the type Callable is not genetic; it cannot be parameterized with arguments<Ineger>
the type Future is not genetic ; it cannot be parameterized with arguments<Integer>

can you please tell me what is wrong????

it is written that eclipse Release 3.2.0
did you compile the above code without any addition?? because I have sent you the code without adding your method and it is working fine but when I add your method alot of errors occur
sorry I have posted the code in wrong way
my code is below:
[code]
package final_project;
import java.io.*;
import java.util.*;

public class Minimization {

static String line1;
static String line2;
static String line3;
static String line4;
static String gate_line;
static String [] gate_name;
static String sub_line3;
static String output_node;
static int node_num;
static String pattern_SA;
static Vector vector_SA= new Vector();
static String temp_SA ;
static String[] bits;
static Vector vector_temp= new Vector();
static int sw_on_same_dir[][] ;
static int swa_diff[][];
static int charging[][] ;
static int discharging[][] ;
static String f_string;
static String s_string;
static String[] bit_fs;
static Vector Orig_test_Pattern= new Vector();
static Vector test_Pattern_after_filling= new Vector();
static int output_node_no ;
static int input_node_no;
static String[] input_node;
static String[] input_more_1;
static int gate_no;
static String num_gate;
static String [] input_1_gate;
static String [] input_2_gate;
static String [] input_3_gate;
static String [] input_4_gate;
static String [] input_5_gate;
static String [] input_6_gate;
static String [] input_7_gate;
static String [] input_8_gate;
static String [] input_9_gate;
static int count [];
static String [][]sub_string_testvec;
static int min_same_direction;
static int min_difference;
static String max;

////////////////////////////////////////////////////////////////////////////////
// method to get the bits of pattern
/////////////////////////////////////////////////////////////////////////////////

static void get_bit(String temp_SA){
bits = new String[temp_SA.length()];
int nex_bit=1;
for (int i=0; i< temp_SA.length();i++){
bits[i] = temp_SA.substring(i,nex_bit);
nex_bit++;
}
} // end of get_bit

////////////////////////////////////////////////////////////////////////////////
//method to calculate the sw( number of bits switching on the same direction)
////////////////////////////////////////////////////////////////////////////////

static void calculat_SW(Vector vector_temp){

sw_on_same_dir = new int[vector_temp.size()][vector_temp.size()] ;
swa_diff = new int[vector_temp.size()][vector_temp.size()] ;
charging = new int [vector_temp.size()][vector_temp.size()];
discharging = new int [vector_temp.size()][vector_temp.size()];
bit_fs= new String[node_num];

//////////////////////////////////////////////////////////////////////////////////
// intialization of sw on the same dire array/////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////

for ( int i=0;i<vector_temp.size();i++) {
for (int j=0;j<vector_temp.size();j++){
sw_on_same_dir[i][j]=0;}}
///////////////////////////////////////////////////////////////////////////////////
// intialization of sw difference array////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

for ( int i=0;i<vector_temp.size();i++) {
for (int j=0;j<vector_temp.size();j++){
swa_diff[i][j]=0;}}
/////////////////////////////////////////////////////////////////////////////////
// intialization of charging array///////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
for ( int i=0;i<vector_temp.size();i++) {
for (int j=0;j<vector_temp.size();j++){
charging[i][j]=0;}}
///////////////////////////////////////////////////////////////////////////////
// intialization of discharging array//////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
for ( int i=0;i<vector_temp.size();i++) {
for (int j=0;j<vector_temp.size();j++){
discharging[i][j]=0;}}
//////////////////////////////////////////////////////////////////////////
// end of intialization//////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
// compute the charging, dicharging////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

for (int i=0;i<vector_temp.size();i++){
f_string = vector_temp.get(i).toString();
get_bit(f_string);
for (int z=0;z<node_num;z++){
bit_fs[z]=bits[z];}


for (int j=0;j<vector_temp.size();j++){
s_string= vector_temp.get(j).toString();
get_bit(s_string);

for ( int f=0; f<node_num;f++){
if ((bit_fs[f].equals("0")) && (bits[f].equals("1")))
charging[i][j]++;


else if ((bit_fs[f].equals("1")) && (bits[f].equals("0")))
discharging[i][j]++;
}
}
}
//////////////////////////////////////////////////////////////////////////////
//calculating sw,and total for every two vectors/////////////////////////////
//////////////////////////////////////////////////////////////////////////////

for ( int i=0;i<vector_temp.size();i++)
{
for (int j=0;j<vector_temp.size();j++){
swa_diff[i][j]=charging[i][j]+discharging[i][j];
if ( charging [i][j]> discharging[i][j])
sw_on_same_dir[i][j]= charging[i][j];

else
sw_on_same_dir[i][j]= discharging[i][j];
}
}
}
//////////////////////////////////////////////////////////////////////////////
///method to calculate the minimum sw value///////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
static void Min_SW(Vector x1){
calculat_SW(x1);
min_same_direction=sw_on_same_dir[0][1];
for ( int i=0;i<x1.size();i++){
for ( int j=0;j<x1.size();j++){
if (sw_on_same_dir[i][j]<min_same_direction && sw_on_same_dir[i][j]!=0)
min_same_direction=sw_on_same_dir[i][j];
}
}
}
//////////////////////////////////////////////////////////////////////////////////
///method to calculate the minimum total//////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
static void Min_sw_diff(Vector x3){
calculat_SW(x3);
min_difference=swa_diff[0][1];
for ( int i=0;i<x3.size();i++){
for ( int j=0;j<x3.size();j++){
if (swa_diff[i][j]<min_difference && swa_diff[i][j]!=0)
min_difference=swa_diff[i][j];}}
}

static void Max_gate_name(){
int count_nand=0;
int count_and=0;
int count_nor=0;
int count_or=0;
int count_xor=0;
int count_not=0;

for(int k=0;k<gate_no;k++){
if ( gate_name[k].equals("nand(")){
count_nand++;}

if ( gate_name[k].equals("and(")){
count_and++;}

if ( gate_name[k].equals("nor(")){
count_nor++;}

if ( gate_name[k].equals("or(")){
count_or++;}

// if ( gate_name[k].equals("xor(")){
// count_xor++;}

//if ( gate_name[k].equals("not(")){
// count_not++;}
}

int max_gate=0;

if ( count_nand>max_gate){
max_gate=count_nand;
max="nand";
}

else if( count_and>max_gate){
max_gate=count_and;
max="and";
}

else if (count_or>max_gate){
max_gate=count_or;
max="or";
}
else if(count_nor>max_gate){
max_gate=count_nor;
max="nor";
}
// else if(count_xor> max_gate){
// max_gate=count_xor;
// max="xor";
// }
// else if (count_not>max_gate){
// max_gate=count_not;
// max="not";
//}
}
/////////////////////////////////////////////////////////////////////////////////
// main method /////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

public static void main(String[] args) {

/////////////////////////////////////////////////////////////////////////////
////////input file name/////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////


File file1 = new File("C:\\Users/Fatooma/Desktop/atpg/t1.txt");
File file2 = new File("C:\\Users/Fatooma/Desktop/atpg/c17.tc");
File file3 = new File("C:\\Users/Fatooma/Desktop/atpg/c17.bench");

/////////////////////////////////////////////////////////////////////////////
//// start reading lines////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////

try {
Scanner inFile1 = new Scanner(new FileInputStream(file1));
BufferedReader reader1 = new BufferedReader(new FileReader(file1));
line1=null;
line1 = reader1.readLine() ;

Scanner inFile2 = new Scanner(new FileInputStream(file2));
BufferedReader reader2 = new BufferedReader(new FileReader(file2));
line2=null;
line2 = reader2.readLine() ;





Scanner inFile3 = new Scanner(new FileInputStream(file3));
BufferedReader reader3 = new BufferedReader(new FileReader(file3));
line3=null;
line3 = reader3.readLine() ;

//Scanner inFile4 = new Scanner(new FileInputStream(file4));
//BufferedReader reader4 = new BufferedReader(new FileReader(file4));
//line4=null;
//line4 = reader4.readLine() ;

///////////////////////////////////////////////////////////////////////////
///// while there is more lines///////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

for (int x=0;x<2;x++){
line1 = inFile1.nextLine();}


while (inFile1.hasNextLine()) {
line1 = inFile1.nextLine();
pattern_SA = line1;
node_num = pattern_SA.length();
vector_SA.add(pattern_SA);
}
System.out.println(" the length "+ node_num);
System.out.println(" the patterns of switching activity are "+ vector_SA);
calculat_SW(vector_SA);
for (int i=0;i<vector_SA.size();i++){
for(int j=0;j<vector_SA.size();j++){
System.out.println (" switching on the same direction " +sw_on_same_dir[i][j]);
System.out.println (" charging " +charging[i][j]);
System.out.println (" discharging " +discharging[i][j]);
System.out.println (" hammaing distance between switching activity " +swa_diff[i][j]);

}

}inFile1.close();


////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////saving test vectors/////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////


while (inFile2.hasNextLine()) {
line2 = inFile2.nextLine();
Orig_test_Pattern.add(line2);
if(inFile2.hasNextLine())
line2 = inFile2.nextLine();}

System.out.println(" the test vectors are "+ Orig_test_Pattern);

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////// saving test vectors, number of primary inputs, number of outputs, number of gates/////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

line3 = inFile3.nextLine();
line3 = inFile3.nextLine();

System.out.println(" the line "+ line3);
StringTokenizer token1 = new StringTokenizer(line3);
token1.nextToken();
String num_input=token1.nextToken();
input_node_no=Integer.parseInt(num_input);
System.out.println(" the input node number "+ input_node_no);

line3 = inFile3.nextLine();

StringTokenizer token2 = new StringTokenizer(line3);
token2.nextToken();
String num_output=token2.nextToken();
output_node_no=Integer.parseInt(num_output);
System.out.println(" the output node number "+ output_node_no);

line3 = inFile3.nextLine();
line3 = inFile3.nextLine();

StringTokenizer token3 = new StringTokenizer(line3);
token3.nextToken();
String num_gate=token3.nextToken();
gate_no=Integer.parseInt(num_gate);
System.out.println(" the number of gate "+ gate_no);

line3 = inFile3.nextLine();
line3 = inFile3.nextLine();
////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////saving node names, gate names ////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

input_node = new String[input_node_no];
for(int x=0;x<input_node_no;x++){
StringTokenizer token4 = new StringTokenizer(line3);
token4.nextToken();
input_node[x]=token4.nextToken();
line3 = inFile3.nextLine();}

for(int k=0;k<output_node_no+1;k++){
line3 = inFile3.nextLine();}



gate_name = new String[gate_no];
input_1_gate = new String[gate_no];
input_2_gate = new String[gate_no];
input_3_gate = new String[gate_no];
input_4_gate = new String[gate_no];
input_5_gate = new String[gate_no];
input_6_gate = new String[gate_no];
input_7_gate = new String[gate_no];
input_8_gate = new String[gate_no];
input_9_gate = new String[gate_no];


while (inFile3.hasNextLine()){
for(int j=0;j<gate_no;j++){
line3=inFile3.nextLine();

StringTokenizer token5 = new StringTokenizer(line3);
token5.nextToken();
token5.nextToken();
gate_name[j]= token5.nextToken();



StringTokenizer token6 = new StringTokenizer(line3);
int num_token=token6.countTokens();
token6.nextToken();
token6.nextToken();
token6.nextToken();


input_1_gate[j]= token6.nextToken();

if (num_token==7|| num_token>7){
token6.nextToken();
input_2_gate[j]= token6.nextToken();}

if(num_token<7){
input_2_gate[j]=null;
}



if (num_token==9|| num_token>9){
token6.nextToken();
input_3_gate[j]= token6.nextToken();}

if(num_token<9){
input_3_gate[j]=null;
}



if (num_token==11|| num_token>11){
token6.nextToken();
input_4_gate[j]= token6.nextToken();}

if(num_token<11){
input_4_gate[j]=null;
}



if (num_token==13|| num_token>13){
token6.nextToken();
input_5_gate[j]= token6.nextToken();}

if(num_token<13){
input_5_gate[j]=null;
}



if (num_token==15|| num_token>15){
token6.nextToken();
input_6_gate[j]= token6.nextToken();}

if(num_token<15){
input_6_gate[j]=null;
}



if (num_token==17|| num_token>17){
token6.nextToken();
input_7_gate[j]= token6.nextToken();}

if(num_token<17){
input_7_gate[j]=null;
}



if (num_token==19|| num_token>19){
token6.nextToken();
input_8_gate[j]= token6.nextToken();}

if(num_token<19){
input_8_gate[j]=null;
}



if (num_token==21|| num_token>21){
token6.nextToken();
input_9_gate[j]= token6.nextToken();}

if(num_token<21){
input_9_gate[j]=null;}

}}







boolean flag1=false;
boolean flag2=false;
boolean flag3=false;

count=new int[input_node_no];
input_more_1= new String[input_node_no];

for(int x=0;x<input_node_no;x++){
for(int k=0;k<gate_no;k++){

if(input_node[x].equals(input_1_gate[k]) || input_node[x].equals(input_2_gate[k])|| input_node[x].equals(input_3_gate[k]) || input_node[x].equals(input_4_gate[k])|| input_node[x].equals(input_5_gate[k])|| input_node[x].equals(input_6_gate[k])|| input_node[x].equals(input_7_gate[k]) || input_node[x].equals(input_8_gate[k])|| input_node[x].equals(input_9_gate[k])){
count[x]++;

if( count[x]>1){
input_more_1[x]=input_node[x];}

else if ( count[x]==1 ||count[x]<1)
{
input_more_1[x]=null;}


if ( gate_name[k].equals("nand(") || gate_name[k].equals("and(")){
flag1=false; }

if ( gate_name[k].equals("nor(") || gate_name[k].equals("or(")){
flag1=true;}

if ( gate_name[k].equals("xor(") || gate_name[k].equals("not(")){
flag3=true; }
} }}


int count_more_1_nand=0;
int count_more_1_nor=0;
int count_more_1_and=0;
int count_more_1_or=0;
int count_more_1_xor=0;
int count_more_1_not=0;


for(int x=0;x<input_node_no;x++){
for(int k=0;k<gate_no;k++){
if (input_more_1[x]!=null){
if(input_more_1[x].equals(input_1_gate[k]) || input_more_1[x].equals(input_2_gate[k]) || input_more_1[x].equals(input_3_gate[k]) || input_more_1[x].equals(input_4_gate[k]) || input_more_1[x].equals(input_5_gate[k]) || input_more_1[x].equals(input_6_gate[k]) || input_more_1[x].equals(input_7_gate[k]) || input_more_1[x].equals(input_8_gate[k])|| input_more_1[x].equals(input_9_gate[k])){
System.out.println(" the gate name with more than input "+ gate_name[k]+" the input is "+ input_more_1[x]);
if ( gate_name[k].equals("nand("))
count_more_1_nand++;
if ( gate_name[k].equals("nor("))
count_more_1_nor++;
if ( gate_name[k].equals("and("))
count_more_1_and++;
if ( gate_name[k].equals("or("))
count_more_1_or++;
if ( gate_name[k].equals("xor("))
count_more_1_xor++;
if ( gate_name[k].equals("not("))
count_more_1_not++;

if (count[x]==count_more_1_nand|| count[x]==count_more_1_nor|| count[x]==count_more_1_and|| count[x]==count_more_1_or){
{flag2=true;}
if( count[x]==count_more_1_nand+count_more_1_and)
{flag2=true;}
if( count[x]==count_more_1_nor+count_more_1_or)
{flag2=true;}
if (count[x]==count_more_1_xor|| count[x]==count_more_1_not)
{flag3=true;}
if (count[x]==count_more_1_xor+count_more_1_not)
{flag3=true;}
System.out.println(" the count with more than input "+ count[x]);
} }} }}


test_Pattern_after_filling.setSize(Orig_test_Pattern.size());



for ( int u=0; u< Orig_test_Pattern.size();u++){
String result = "";
StringTokenizer token7 = new StringTokenizer(Orig_test_Pattern.get(u).toString());

int token7_num=token7.countTokens();
if ( token7.hasMoreTokens()){
token7.nextToken();}

for(int x=0;x<token7_num-1;x++){
if ( token7.hasMoreTokens()){
String ff= token7.nextToken();
// for ( int g=0;g<input_node_no;g++){
sub_string_testvec=new String [token7_num-1][Orig_test_Pattern.size()];

if ( ff.substring(2,3).equals("x")){

if (input_more_1[x]==null){

if ( flag1==true ){
sub_string_testvec[x][u]=ff.substring(0,2)+"1"; }
if ( flag1==false ){
sub_string_testvec[x][u]=ff.substring(0,2)+"0"; }
if (flag3==true){
Max_gate_name();
if (max.equals("nand")|| max.equals("and")){
sub_string_testvec[x][u]=ff.substring(0,2)+"0";
}
if (max.equals("nor")|| max.equals("or")){
sub_string_testvec[x][u]=ff.substring(0,2)+"1";
}}
}

if (input_more_1[x]!=null && flag2==true ){

if ( flag1==true && input_more_1[x].equals(ff.substring (0,1)) ){
sub_string_testvec[x][u]=ff.substring(0,2)+"1";}

if ( flag1==false && input_more_1[x].equals(ff.substring (0,1)) ){
sub_string_testvec[x][u]=ff.substring(0,2)+"0"; }

if (flag3==true){
Max_gate_name();
if (max.equals("nand")|| max.equals("and")){
sub_string_testvec[x][u]=ff.substring(0,2)+"0";
}
if (max.equals("nor")|| max.equals("or")){
sub_string_testvec[x][u]=ff.substring(0,2)+"1";
}}

}
}
if (input_more_1[x]!=null && flag2==false || input_more_1[x]!=null && flag3==true){
Max_gate_name();
if (max.equals("nand")|| max.equals("and")){
sub_string_testvec[x][u]=ff.substring(0,2)+"0";
}
if (max.equals("nor")|| max.equals("or")){
sub_string_testvec[x][u]=ff.substring(0,2)+"1";
}

}
else if ( ! ff.substring(2,3).equals("x") ){
sub_string_testvec[x][u]=ff.substring(0,2)+ff.substring(2,3);}
}

result += sub_string_testvec[x][u]+" ";
System.out.println("the result is "+ result);

}
String line_test_vec= "Test: "+result;

test_Pattern_after_filling.setElementAt(line_test_vec, u);
}
System.out.println(test_Pattern_after_filling);


inFile2.close();


FileWriter writer2= new FileWriter(file2);


for ( int g=0;g<test_Pattern_after_filling.size();g++){
writer2.write(test_Pattern_after_filling.get(g).toString());
writer2.write("\r\n\r\n");

}

writer2.close();





} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

}}





[/cpde]
I hope that I can find solution to my problem
thanks
thanks for the code but I have errors at the following lines

and error at this line

and

and

and

and


I have got these errors. Maybe I'm doing some thing wrong! please if you know how to fix these errors and fix my problem please reply I'm waiting
hello everyone
I have question
I need to call c program from java
I don't have problem with application or exe file in c it is working but when I call it from java it doesn't work there is no error but it doesn't work because when I execute the c program the black screen must be appeared so that I can enter the input file and then it produces the output file but in java I cann't see the black screen so please can you tell me the problem
I have used the following code to call c from java:
hello everyone
I hope that someone can help me
I have tried to run c code in java using Runtime but I got the following error:
Debug assertion failed
file:fprintf
line:56
althogh the c code is working correctly using visual c++ 6.0 and does not generate error and I'm able to run it using dll but I'm unable to run it using java

Hlppppppppppppppp please
thanks in advance
 
Forum Index » Profile for sara12345 » Messages posted by sara12345
Go to:   
Powered by JForum 2.1.9 © JForum Team
This site run by Scott Dunbar of Xigole Systems. © 2005-2012 - Scott Dunbar
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners
hotjoe.com, xigole.com, and Scott Dunbar have no affiliation with Oracle