Recently i created a Penalization calculator which is written in Perl [.exe] language to calculate panel required to manufacture a printed circuited board. I did it for one of our customers. The output screen for this calculator looks like below:

Calculator-300x284

I wanted to integrate the same penalization calculator in one of the projects which is written in java.

So I code like mentioned below to call exe in java.

package panelcalculator;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class PanelCalculator {

    public String calculate(String strParms) 
    {
        String result = “”;
        try {
            Runtime runtime = Runtime.getRuntime();
            Process process = runtime.exec(strParms);
            InputStream inStream = process.getInputStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(inStream));
            String data = “”;
            while ((data = reader.readLine()) != null) {
            	result += data + ” “;
        	}
            reader.close();
            inStream.close();
            process.destroy();
    	} 
        catch (Exception e) 
        {
        	result = e.toString();
        }
    	return result.trim();
    }

    public static void main(String arg[]) 
    {
    
        PanelCalculator pc = new PanelCalculator();
        String result = pc.calculate(“D:\\MyWebapp\\PanelizationCalculator\\PanelCalculator.exe PanelX=12 PanelY=18 NLayers=2 Spec=\”IPC-6012 Class 2\” BoardX=12 BoardY=2.25 Spacing=0.2 			LaserDrill=N Flex=N Impedance=N ImpSingleEnd=0 ImpDiff=0 EdgePlating=N”);
        if(result!=null){
            System.out.println(result);
        }
    }

}

And finally i got output like following, exactly the same as I wanted:

UsableX=10.2 UsableY=14.6 MaxUp=4

Output-300x183

Thank you.
Narendra

About Author
Share this post on: