| | |
How to program under linux
![]() |
•
•
Join Date: May 2009
Posts: 4
Reputation:
Solved Threads: 0
Hi all
I want a help for changing this program to a linux program .
Can anyone help me?
wether is it in c++ or Java.
I want a help for changing this program to a linux program .
Can anyone help me?
wether is it in c++ or Java.
java Syntax (Toggle Plain Text)
import javax.swing.*; import java.awt.*; import java.awt.event.*; class fcfs extends JFrame implements ActionListener { JButton jb[] = new JButton[3]; JTextField jt1[],jt2[]; JLabel jl[],jl1,jl2,jl3; JPanel jp,jp1; Container con; int k,p; String str[] = {"SUBMIT","RESET","EXIT"}; String str1[] = {"Process"," AT","ST","WT","FT","TAT","NTAT"}; public fcfs() { super("fcfs scheduling algoritham"); con = getContentPane(); k= Integer.parseInt(JOptionPane.showInputDialog("Enter number ofprocess")); jl1 = new JLabel("Process"); jl2 = new JLabel("Arival Time"); jl3 = new JLabel("Service Time"); jl = new JLabel[k]; jt1 = new JTextField[k]; jt2 = new JTextField[k]; for(int i=0;i<k;i++) { jl[i] = new JLabel("process"+(i+1)); jt1[i] = new JTextField(10); jt2[i] = new JTextField(10); } for(int i=0;i<3;i++) { jb[i] = new JButton(str[i]); } con.setLayout(new GridLayout(k+2,3)); con.add(jl1); con.add(jl2); con.add(jl3); int l=0; for(int i=0;i<k;i++) { con.add(jl[l]); con.add(jt1[l]); con.add(jt2[l]); l++; } l=0; for(int i=0;i<3;i++) { con.add(jb[l]); jb[l].addActionListener(this); l++; } }//end of constructor public void actionPerformed(ActionEvent ae) { int FT[] = new int[k]; int WT[] = new int[k]; int TAT[] = new int[k]; float NTAT[] = new float[k]; float sum=0; float avg; JPanel main = new JPanel(); main.setLayout(new BorderLayout()); jp = new JPanel(); jp1 = new JPanel(); jp.setLayout(new GridLayout(k+1,7)); jp1.setLayout(new FlowLayout()); if(ae.getSource() == jb[2]) { System.exit(0); } else if(ae.getSource() == jb[0]) { FT[0] = Integer.parseInt(jt1[0].getText()) + Integer.parseInt(jt2[0].getText()); for(int i=0;i<k;i++) { if(i==0) { WT[i] = 0; } else { if(FT[i-1] < Integer.parseInt(jt1[i].getText())) { FT[i] = Integer.parseInt(jt1[i].getText())+Integer.parseInt(jt2[i].getText()); WT[i] = 0; } else { FT[i] = FT[i-1] + Integer.parseInt(jt2[i].getText()); WT[i] = FT[i-1] - Integer.parseInt(jt1[i].getText()); } } TAT[i] = WT[i]+Integer.parseInt(jt2[i].getText()); NTAT[i] = TAT[i]/(Integer.parseInt(jt2[i].getText())); sum = sum+WT[i]; }//end for loop for (int i=0;i<7;i++ ) { jp.add(new JLabel(str1[i])); } for (int i=0;i<k;i++) { jp.add(new JLabel("process"+(i+1))); jp.add(new JLabel(" "+Integer.parseInt(jt1[i].getText()))); jp.add(new JLabel(""+Integer.parseInt(jt2[i].getText()))); jp.add(new JLabel(""+WT[i])); jp.add(new JLabel(""+FT[i])); jp.add(new JLabel(""+TAT[i])); jp.add(new JLabel(""+NTAT[i])); } avg = sum/k; String str2 = "Average Waiting Time is "+ avg; jp1.add(new JLabel(str2)); main.add(jp,BorderLayout.NORTH); main.add(jp1,BorderLayout.SOUTH); JOptionPane.showMessageDialog(null,main,"output",JOptionPane.PLAIN_MESSAGE ); } else if(ae.getSource() == jb[1]) { setVisible(false); fcfs window = new fcfs(); window.setSize(400,300); window.setVisible(true); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }//END ACTION PERFORMED public static void main(String[] args) { fcfs window = new fcfs(); window.setSize(400,300); window.setVisible(true); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }//end main }//end class
Last edited by John A; May 20th, 2009 at 9:29 pm. Reason: added code tags, removed color tags
well that is obviously Java, and the code should need to change for linux. next time, you should use code tags around your code.
Dear FussyRose,
Your program is written for any hardware (because you choose java platform). After all, Java source code needs compilation if you want to change the os.
so, compile your java program and run it on Linux without hesitation.
Good Luck
Your program is written for any hardware (because you choose java platform). After all, Java source code needs compilation if you want to change the os.
so, compile your java program and run it on Linux without hesitation.
Good Luck
Failure is not fatal, but failure to change might be. - John Wooden
•
•
Join Date: Apr 2008
Posts: 972
Reputation:
Solved Threads: 146
Not true. Compiled class files and jar files are the same across all OSs. An executable jar created in Windows will run in Linux (provided it contains no Windows-specific code).
@OP : This program isn't written by you isn't it ? Since you do not even know whether it's for C++ or Java. So before I give you an advice, unlike others who I guess haven't put a thought to this, I would like to know the source of this program. Why you would like to change it and Why you are working with something that you even do not know the origin of ?
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
•
•
Join Date: Apr 2008
Posts: 972
Reputation:
Solved Threads: 146
When you compile java you can specify the minimum version of JVM that it will run on, so if you've compiled for 1.4 it won't run on 1.2 - but that's not an OS issue, it's a Java version issue. If you are referring to non-Sun JVMs then that's an issue of whether they are compatible with Sun's reference implementation or not.
In short - if your compiled code runs on one platform with Sun's JVM, it will run on any other platform's Sun JVM that is sufficiently recent.
In short - if your compiled code runs on one platform with Sun's JVM, it will run on any other platform's Sun JVM that is sufficiently recent.
•
•
•
•
When you compile java you can specify the minimum version of JVM that it will run on, so if you've compiled for 1.4 it won't run on 1.2 - but that's not an OS issue, it's a Java version issue. If you are referring to non-Sun JVMs then that's an issue of whether they are compatible with Sun's reference implementation or not.
In short - if your compiled code runs on one platform with Sun's JVM, it will run on any other platform's Sun JVM that is sufficiently recent.
Failure is not fatal, but failure to change might be. - John Wooden
![]() |
Similar Threads
- helloworld program error in linux server (Java)
- Porting simple program from linux to minix (Kernels and Modules)
- Compile C++ program for different version of GCC Linux (C++)
- How to Program on Linux...... (Window and Desktop Managers)
- Call external program in C++ (Linux) (C++)
- c/c++ program to read rtf file's text in linux (C++)
- executing the normal program from linux.rc - different bahaviour (Kernels and Modules)
- how to test a software program on linux (C)
Other Threads in the Java Forum
- Previous Thread: How to Find System Info Through Java
- Next Thread: carmovement project
| Thread Tools | Search this Thread |
911 actionlistener addball addressbook android api append applet application array arrays automation binary bluetooth button character chat class client code component consumer css csv database desktop eclipse ee error fractal ftp game givemetehcodez graphics gui html ide image integer j2me japplet java javaarraylist javac javaee javaprojects jni jpanel julia jvm linked linux list loan mac map method methods mobile netbeans newbie objects online oriented output panel phone printf problem program programming project projects properties recursion replaydirector reporting researchinmotion rotatetext rsa scanner se server service set sms software sort sql string swing test threads time transfer tree ubuntu update windows working






