Results 1 to 4 of 4
- 05-29-2009, 03:13 AM #1
Member
- Join Date
- Dec 2008
- Posts
- 50
- Rep Power
- 0
won't run on Java 1.5, I don't know why
I was hoping someone a little more familiar with this language could tell me if there is a method I am using in here that does not allow me to compile or, once compiled, run on the 1.5 version. (By compile I mean I created a JAR file)
This may be really pushing my luck but if someone finds something and knows what I can do to get around it please let me know.
Let me also state that for some reason the IT department in our facility wants to keep us on 1.5 for Oracle reasons. When I archive this and run on a machine with 1.5 it says something to the tune of 'Could not find main class'
Any help would be appreciated, thanks. (Also, I would guess it has something to do with the database connectivity).
Java Code:/** * This program is designed to give rochester service * the ability to view employee performance * * @author Geoff Berl * @version 1.00 */ import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.text.DecimalFormat; public class EmployeeDashboard extends JFrame implements ActionListener { private String[] employeeList; private JButton jbtOK = new JButton("OK"); private JButton jbtClear = new JButton("Clear"); private JButton jbtCancel = new JButton("Cancel"); private JComboBox jcboEmployeeList = new JComboBox(employeeList); private JMenuBar jMenuBar = new JMenuBar(); private JMenuItem jmiClear; private JMenuItem jmiExit; private JMenuItem jmiAbout; private final String AUTHOR = "Geoff Berl"; private final double VERSION = 1.00; private final String UPDATE = "3/19/2009"; //private JOptionPane aboutWindow = new JOptionPane(); DecimalFormat output = new DecimalFormat("0.00"); //Main method public static void main(String[] args) { //Initiate the window EmployeeDashboard window = new EmployeeDashboard(); //Initiate the database and create the connection String pfile = "ReportDB.dat"; ReportDB db = new ReportDB(pfile); //db.setConnection(pfile); //db.createTable(); //employeeList = db.listNames(); db.listNames(); //db.displayTable(); db.close(); } /** This is the InvestCalc method @postcondition Generates the GUI for the investment calculator */ public EmployeeDashboard() { //Create panel(s) JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); //Set the window title and size setTitle("Employee Dashboard"); setSize(300, 200); //use FlowLayout to align components setLayout(new BorderLayout()); panel1.setLayout(new GridLayout(4, 2, 10, 0)); panel2.setLayout(new FlowLayout()); //Menu stuff setJMenuBar(jMenuBar); JMenu fileMenu = new JMenu("File"); JMenu helpMenu = new JMenu("Help"); jMenuBar.add(fileMenu); jMenuBar.add(helpMenu); fileMenu.add(jmiClear = new JMenuItem("Clear", 'R')); fileMenu.addSeparator(); fileMenu.add(jmiExit = new JMenuItem("Exit",'E')); helpMenu.add(jmiAbout = new JMenuItem("About",'T')); // Set keyboard accelerators jmiClear.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK)); jmiExit.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK)); jmiAbout.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK)); //Add components add(panel1, BorderLayout.CENTER); panel1.add(new JLabel("Select Employee:")); panel1.add(jcboEmployeeList); panel2.add(jbtOK); panel2.add(jbtClear); panel2.add(jbtCancel); add(panel2, BorderLayout.SOUTH); //misc operations setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Center the window on the screen setLocationRelativeTo(null); setVisible(true); //Register listeners jbtOK.addActionListener(this); jbtClear.addActionListener(this); jbtCancel.addActionListener(this); jmiExit.addActionListener(this); jmiAbout.addActionListener(this); jmiClear.addActionListener(this); } /** actionPerformed is used to handle ActionEvents from menu items and buttons*/ public void actionPerformed(ActionEvent e) { String actionCommand = e.getActionCommand(); //if it's a menu item this statement will handle it if (e.getSource() instanceof JMenuItem) { if ("Clear".equals(actionCommand)) clear(); else if ("About".equals(actionCommand)) respondToAbout(); else if ("Exit".equals(actionCommand)) System.exit(0); } //Otherwise, check it it was a button if(e.getSource() == jbtOK) System.out.println("You've selected " + checkData()); if(e.getSource() == jbtClear) clear(); if(e.getSource() == jbtCancel) System.exit(0); } //end actionPerformed /** This is the respondToAbout method @postcondition JOptionPane is displayed with information about the program. */ public void respondToAbout() { JOptionPane.showMessageDialog(null, "Employee Dashboard V" + output.format(VERSION) + "\nCreated by: " + AUTHOR + "\n" + "Last updated: " + UPDATE, "About", JOptionPane.INFORMATION_MESSAGE); } /** This is the clear method @postcondition all fields are returned to their original states */ public void clear() { jcboEmployeeList.setSelectedIndex(0); } public Object checkData() { return jcboEmployeeList.getSelectedItem(); } }
- 05-29-2009, 03:30 AM #2
Senior Member
- Join Date
- Mar 2009
- Posts
- 552
- Rep Power
- 5
I'm going to say this: The error looks like a jar file error... I would guess that you are not creating your manifest file correctly
If the above doesn't make sense to you, ignore it, but remember it - might be useful!
And if you just randomly taught yourself to program, well... you're just like me!
- 05-29-2009, 04:06 AM #3
Member
- Join Date
- Dec 2008
- Posts
- 50
- Rep Power
- 0
Well, with that said I will walk you through exactly what happened.
1. I tried to create the JAR file, it gave some error like (The registry shows version 1.5, you need 1.6 to create a JAR)
2. I upgraded my computer to 1.6 and the program ran fine
3. I sent it to a colleague to test it out and he said it didn't work
4. I tried it under my name on a different computer and alas, did not work
5. I upgraded the different computer to 1.6 and it works fine.
I'm not overly familiar with Java but if it works in one version why would my Manifest have anything to do with that. Additionally, why would it tell me I needed 1.6 in order to create the JAR file?
Here are the contents of my manifest:
Manifest-Version: 1.0
Main-Class: EmployeeDash
Class-Path: V:/Service Rochester/KG Reports/Geoff's Stuff/Database tools/Database/EmployeeDash.jar
- 05-29-2009, 04:11 AM #4
Senior Member
- Join Date
- Mar 2009
- Posts
- 552
- Rep Power
- 5


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks