Results 1 to 10 of 10
Thread: Stand Alone Compiler?
- 04-08-2010, 12:41 AM #1
Member
- Join Date
- Mar 2010
- Posts
- 8
- Rep Power
- 0
Stand Alone Compiler?
Hey all,
I've had to make a few changes to a java app for school. I'm not on my home computer and the one I'm on doesn't have Java. I don't have admin rights, so no way to install the compiler.
Is there a stand alone compiler that I can just run from a folder or something so I can do a quick check on my program?
Thanks.
-
There are online compilers around, but I'm not sure the address. Google might be able to help in this.
- 04-08-2010, 04:11 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
JXXX is one of them. I've use it several times, seems okay for simple applications. Could be fine with complex applications as well, but I've never tried it.
I think best way is to contact your responsible person in your school laboratory and ask him/her to install a compiler there. What's the usage without having those things of a laboratory. :)
- 04-08-2010, 04:15 AM #4
Member
- Join Date
- Mar 2010
- Posts
- 8
- Rep Power
- 0
I take classes online from my school, which is actually about a 2 hour drive from me.
I tried the JXXX compiler, and it comes back with no errors, but I can't get it to run when I download the class file it gives me. I'm not used to Windows, I normally use a Mac.
This is the error I get. I don't know if it is a problem with the computer I'm on now or with my code.
Java Code:Exception in thread "main" java.lang.NoClassDefFoundError: C:\Exercise15_4 Caused by: java.lang.ClassNotFoundException: C:\Exercise15_4 at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) Could not find the main class: C:\Exercise15_4. Program will exit.
- 04-08-2010, 04:21 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Can you post your code here if it's not too long? Are you sure that your class name and physical file name is exactly the same and the main method contains in that class?
- 04-08-2010, 04:25 AM #6
Member
- Join Date
- Mar 2010
- Posts
- 8
- Rep Power
- 0
Java Code:// Exercise15_4.java: Perform add, subtract, multiply, and divide on // double values import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Exercise15_4 extends JFrame implements ActionListener { // Text fields for Number 1, Number 2, and Result private JTextField jtfNum1, jtfNum2, jtfResult; // Buttons "Add", "Subtract", "Multiply" and "Divide" private JButton jbtAdd, jbtSub, jbtMul, jbtDiv, jbtMod, jbtPow, jbtSqu, jbtInv; // Main Method public static void main(String[] args) { Exercise15_4 frame = new Exercise15_4(); frame.pack(); frame.setTitle("Exercise15_4"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } // Default Constructor public Exercise15_4() { // Panel p1 to hold text fields and labels JPanel p1 = new JPanel(); p1.setLayout(new FlowLayout()); p1.add(new JLabel("Number 1")); p1.add(jtfNum1 = new JTextField(3)); p1.add(new JLabel("Number 2")); p1.add(jtfNum2 = new JTextField(3)); p1.add(new JLabel("Result")); p1.add(jtfResult = new JTextField(8)); jtfResult.setEditable(false); jtfResult.setHorizontalAlignment(SwingConstants.RIGHT); // Panel p2 - Add, Subtract, Multiply, Devide JPanel p2 = new JPanel(); p2.setLayout(new FlowLayout()); p2.add(jbtAdd = new JButton("Add")); p2.add(jbtSub = new JButton("Subtract")); p2.add(jbtMul = new JButton("Multiply")); p2.add(jbtDiv = new JButton("Divide")); // Panel p# - Modulo, Power, Square, Inverse JPanel p3 = new JPanel(); p3.setLayout(new FlowLayout()); p3.add(jbtMod = new JButton("Modulo")); p3.add(jbtPow = new JButton("Power")); p3.add(jbtSqu = new JButton("Square")); p3.add(jbtInv = new JButton("Inverse")); // Set mnemonic keys jbtAdd.setMnemonic('A'); jbtSub.setMnemonic('S'); jbtMul.setMnemonic('M'); jbtDiv.setMnemonic('D'); jbtMod.setMnemonic('O'); jbtPow.setMnemonic('P'); jbtSqu.setMnemonic('Q'); jbtInv.setMnemonic('I'); // Add panels to the frame getContentPane().setLayout(new BorderLayout()); getContentPane().add(p1, BorderLayout.CENTER); getContentPane().add(p2, BorderLayout.SOUTH); getContentPane().add(p3, BorderLayout.SOUTH); // Register listeners jbtAdd.addActionListener(this); jbtSub.addActionListener(this); jbtMul.addActionListener(this); jbtDiv.addActionListener(this); jbtMod.addActionListener(this); jbtPow.addActionListener(this); jbtSqu.addActionListener(this); jbtInv.addActionListener(this); } // Handle ActionEvent from buttons and menu items public void actionPerformed(ActionEvent e) { String actionCommand = e.getActionCommand(); // Handle button events if (e.getSource() instanceof JButton) { if ("Add".equals(actionCommand)) calculate('+'); else if ("Subtract".equals(actionCommand)) calculate('-'); else if ("Multiply".equals(actionCommand)) calculate('*'); else if ("Divide".equals(actionCommand)) calculate('/'); else if ("Modulo".equals(actionCommand)) calculate('%'); else if ("Power".equals(actionCommand)) calculate('P'); else if ("Square".equals(actionCommand)) calculate('S'); else if ("Inverse".equals(actionCommand)) calculate('I'); } } // Calculate and show the result in jtfResult private void calculate(char operator) { // Obtain Number 1 and Number 2 double num1 = new Double(jtfNum1.getText().trim()).doubleValue(); double num2 = new Double(jtfNum2.getText().trim()).doubleValue(); double result = 0; // Perform selected operation switch (operator) { case '+': result = num1 + num2; break; case '-': result = num1 - num2; break; case '*': result = num1 * num2; break; case '/': result = num1 / num2; break; case '%': result = num1 % num2; break; case 'P': result = Math.pow(num1, num2); break; case 'S': result = num1 * num1; break; case 'I': result = 1.0 / num1; } // Set result in jtfResult jtfResult.setText(String.valueOf(result)); } }
- 04-08-2010, 04:39 AM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I cannot see any error in your code. Give me a second I'll check it on JXXX and let you know.
- 04-08-2010, 04:45 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
It works fine without an error. I've create the class file as well.
- 04-08-2010, 04:51 AM #9
Member
- Join Date
- Mar 2010
- Posts
- 8
- Rep Power
- 0
I think the problem must be with the JVM on the machine I am using then. I can compile and create the class file with no errors on JXXX, but I can't run it on my JVM locally.
I'll have to try when I get access to my personal laptop.
- 04-08-2010, 04:54 AM #10
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You me the runtime environment. That VM is able to handle all dependencies.
Similar Threads
-
Stand alone applications? HELP!!!
By Atriamax in forum EclipseReplies: 6Last Post: 09-11-2009, 01:56 AM -
What does String args[] stand for?
By Addez in forum New To JavaReplies: 7Last Post: 08-19-2009, 10:24 AM -
compiler,JIT compiler & interpreter
By gamilah in forum New To JavaReplies: 4Last Post: 11-04-2008, 12:32 AM -
Stand Alone Applications?
By djpg2000 in forum New To JavaReplies: 5Last Post: 09-05-2008, 07:23 PM -
Could some plz tell me how to write a stand alone
By quickfingers in forum New To JavaReplies: 25Last Post: 06-28-2008, 04:22 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks