Java programming in GNU/Linux
I'm currently learning Java now as a module in school and I'm using Eclipse IDE in FC2. I compiled this piece of code in Sun's J2SE compiler and it works fine but it doesn't compile under GCJ. package lab2; import javax.
I'm currently learning Java now as a module in school and I'm using Eclipse IDE in FC2. I compiled this piece of code in Sun's J2SE compiler and it works fine but it doesn't compile under GCJ.
package lab2;
import javax.swing.JOptionPane;
import java.util.*;
public class Ex2_06 {
public static void main (String[] args) {
String orderQty;
orderQty = JOptionPane.showInputDialog("What is your order Quantity?");
if (orderQty == null)
JOptionPane.showMessageDialog(null, "You didn't input anything!");
else
if (Integer.parseInt(orderQty) >= 400)
JOptionPane.showMessageDialog(null, "15% discount is offered!");
else
if (Integer.parseInt(orderQty) >= 200)
JOptionPane.showMessageDialog(null, "7% discount is offered!");8
else
if (Integer.parseInt(orderQty) >= 100)
JOptionPane.showMessageDialog(null, "3% discount is offered!");
else
JOptionPane.showMessageDialog(null, "no discount is offered!");
System.exit(0);
}
}
I'm aware that GCJ does not have all of Java's implementations and it seems to me that I can't invoke a GUI in Java. Any workarounds? Hope there are some people here who have coded java in GNU/Linux before.
package lab2;
import javax.swing.JOptionPane;
import java.util.*;
public class Ex2_06 {
public static void main (String[] args) {
String orderQty;
orderQty = JOptionPane.showInputDialog("What is your order Quantity?");
if (orderQty == null)
JOptionPane.showMessageDialog(null, "You didn't input anything!");
else
if (Integer.parseInt(orderQty) >= 400)
JOptionPane.showMessageDialog(null, "15% discount is offered!");
else
if (Integer.parseInt(orderQty) >= 200)
JOptionPane.showMessageDialog(null, "7% discount is offered!");8
else
if (Integer.parseInt(orderQty) >= 100)
JOptionPane.showMessageDialog(null, "3% discount is offered!");
else
JOptionPane.showMessageDialog(null, "no discount is offered!");
System.exit(0);
}
}
I'm aware that GCJ does not have all of Java's implementations and it seems to me that I can't invoke a GUI in Java. Any workarounds? Hope there are some people here who have coded java in GNU/Linux before.
Participate on our website and join the conversation
This topic is archived. New comments cannot be posted and votes cannot be cast.
Responses to this topic
What's the "8" doing after the statement "7% discount....);" ?
Can't you use Netbeans to write and compile your Java programs under Linux.? I'm thinking it is the same thing as in windows where it looks all nice with a text editor, debugger, package manager, etc. Last time I checked suns website I though they had a Netbeans for Linux.
Can't you use Netbeans to write and compile your Java programs under Linux.? I'm thinking it is the same thing as in windows where it looks all nice with a text editor, debugger, package manager, etc. Last time I checked suns website I though they had a Netbeans for Linux.
Some of the swing / awt stuff is implemented in the latest version of gcj classpath, but probably not in the version installed on your system (not sure though).
If you want to do GUIs in gcj though you might check on the SWT toolkit that Eclipse itself uses, or something like gtk or qt for java.
Nick
If you want to do GUIs in gcj though you might check on the SWT toolkit that Eclipse itself uses, or something like gtk or qt for java.
Nick