A small java construct(iam a novice)

public class Test{
public static void main(String[] args){
int i=0;
for(int j=0;j<10;j++){
i=i++;
System.out.println(i);
OUTPUT is '0'.but how?
I expected 10.
how i++ works here.

public class Test{
public static void main(String[] args){
int i=0;
for(int j=0;j<10;j++){
i=i++;
System.out.println(i);
OUTPUT is '0'.but how?
I expected 10.
how i++ works here.Any teacher that assigns this question should be shot for being a moron. If every CS 101 teacher assigning this question this year?

Similar Messages

  • Need help in writing a small java code

    Hi,
    I have a small requirement where I need write a small java code. I am thinking of using array. Please suggest if you know the solution:
    1. Need to compare user logon id is preset in the lookup table or not.
    2. If user id present in the lookup then send type "A" mail
    3. If user id in not present in the lookup then send type "B" email.
    Please suggest.
    Thanks,
    Kalpana.

    use this code . you have to pass userlogin and lookup name
    Public String GetEmail(String UserLogin,String lookupcode)
    String email;
    try{
    tcLookupOperationIntf lookupIntf = Platform.getService(tcLookupOperationIntf.class);
    HashMap<String, String> lookupValues = getLookupHashMap(lookupIntf, lookupCode);
    String found = lookupValues.get(UserLogin);
    if (found!=null) email= "EMAIL A";
    else
    email= "EMAIL B";
    }catch(Exception e){}
    return email;
    private HashMap<String, String> getLookupHashMap(tcLookupOperationsIntf lookupOperationsIntf, String lookupCode)throws tcAPIException,tcInvalidLookupException,tcColumnNotFoundException {
    HashMap<String, String> lookupMap = new HashMap<String, String>();
              tcResultSet resultLookupHashMap = lookupOperationsIntf
                        .getLookupValues(lookupCode);
              int countResultLookupHashMap = resultLookupHashMap.getRowCount();
    if (countResultLookupHashMap > 0) {
                   for (int i = 0; i < countResultLookupHashMap; i++) {
                        resultLookupHashMap.goToRow(i);
                        lookupMap.put(resultLookupHashMap..getStringValue("Lookup Definition.Lookup Code Information.Code Key"),
    resultLookupHashMap.getStringValue("Lookup Definition.Lookup Code Information.Decode"));
    return lookupMap;
    }

  • Problem with small java program

    need some help with a small Java assignment I am doing.
    When I compile the code i get 2 errors they are
    invalid method declaration: return type required
    public CreateRandomFile() LINE 87
    ^
    cannot resolve symbol
    new CreateRandomFile(); LINE 112
    ^
    Any help is greatly appreciated
    **********CODE BEGINS HERE ***********************
    import javax.swing.*;
    import java.io.*;
    import BreezySwing.*;
    public class RandomTest extends GBFrame
    JLabel accLabel = addLabel("Account Number",1,1,1,1);
    IntegerField accField = addIntegerField(0,1,2,1,1);
    JLabel firstLabel = addLabel("First Name",2,1,1,1);
    JTextField firstField = addTextField("",2,2,1,1);
    JLabel lastLabel = addLabel("Last Name",3,1,1,1);
    JTextField lastField = addTextField("",3,2,1,1);
    JTextArea resultArea = addTextArea("",4,1,2,3);
    JButton acceptButton = addButton("Accept",7,1,2,1);
    JButton accessButton = addButton("Access",8,1,2,1);
    JButton clearButton = addButton("Clear",9,1,2,1);
    private RandomAccessFile file;
    public void buttonClicked(JButton buttonObj)
    if (buttonObj == acceptButton)
    else
    if (buttonObj == accessButton)
    else
    accField.setNumber(0);
    resultArea.setText("");
    firstField.setText("");
    lastField.setText("");
    private void openFile()
    FileOutputStream foStream = new FileOutputStream ("acc.dat");
    ObjectOutputStream doStream = new ObjectOutputStream (foStream);
    if ("acc.dat" == null || "acc.dat".equals(""))
    System.out.println("Invalid File Name");
    else
    try{
    file = new RandomAccessFile ("acc.dat","rw");
    catch (IOException e)
    System.out.println("File does not exist or Invalid File Name");
    private Record getRecord()
    Record record = new Record();
    int accountNumber;
    try{
    accountNumber = Integer.parseInt(accField.getText());
    if (accountNumber <1 || accountNumber >100)
    System.out.println("Account doesn't exist");
    return null;
    file.seek((accountNumber -1)*Record.size());
    record.read(file);
    catch (NumberFormatException nfe)
    System.out.println("Account does not exist");
    System.out.println("Invalid Number Format");
    catch (IOException io)
    System.out.println("Error reading file");
    return record;
    public createRandomFile() // <----- ERROR HERE
    Record blank = new Record();
    openFile();
    try{
    file = new RandomAccessFile("acc.dat", "rw");
    for (int i=0;i<100;i++)
    blank.write(file);
    System.exit(0);
    catch (IOException e )
    System.out.println("File doesn't exist");
    System.out.println("Invalid File Name");
    System.exit(1);
    public static void main(String args[])
    JFrame tpo = new RandomTest();
    tpo.setTitle("Assignment 1");
    tpo.setSize(200,330);
    tpo.setVisible(true);
    new createRandomFile(); // <--- ERROR HERE
    }

    I changed the things you suggested by have a new error of
    cannot resolve symbol
    symbol : method createRandomFile ()
    location: class javax.swing.JFrame
    tpo.createRandomFile();
    ^
    **************new code here***************************
    import javax.swing.*;
    import java.io.*;
    import BreezySwing.*;
    public class RandomTest extends GBFrame
         JLabel accLabel = addLabel("Account Number",1,1,1,1);
         IntegerField accField = addIntegerField(0,1,2,1,1);
         JLabel firstLabel = addLabel("First Name",2,1,1,1);
         JTextField firstField = addTextField("",2,2,1,1);
         JLabel lastLabel = addLabel("Last Name",3,1,1,1);
         JTextField lastField = addTextField("",3,2,1,1);
    JTextArea resultArea = addTextArea("",4,1,2,3);
    JButton acceptButton = addButton("Accept",7,1,2,1);
    JButton accessButton = addButton("Access",8,1,2,1);
         JButton clearButton = addButton("Clear",9,1,2,1);
         private RandomAccessFile file;
    public void buttonClicked(JButton buttonObj)
         if (buttonObj == acceptButton)
         else
         if (buttonObj == accessButton)
         else
         accField.setNumber(0);
         resultArea.setText("");
         firstField.setText("");
         lastField.setText("");
    private void openFile()
         FileOutputStream foStream = new FileOutputStream ("acc.dat");
         ObjectOutputStream doStream = new ObjectOutputStream (foStream);
         if ("acc.dat" == null || "acc.dat".equals(""))
         System.out.println("Invalid File Name");
         else
         try{
              file = new RandomAccessFile ("acc.dat","rw");
         catch (IOException e)
              System.out.println("File does not exist or Invalid File Name");
    private Record getRecord()
         Record record = new Record();
         int accountNumber;
         try{
              accountNumber = Integer.parseInt(accField.getText());
         if (accountNumber <1 || accountNumber >100)
              System.out.println("Account doesn't exist");
              return null;
         file.seek((accountNumber -1)*Record.size());
         record.read(file);
         catch (NumberFormatException nfe)
         System.out.println("Account does not exist");
         System.out.println("Invalid Number Format");
         catch (IOException io)
              System.out.println("Error reading file");
    return record;
    public void createRandomFile()
    Record blank = new Record();
    openFile();
    try{
         file = new RandomAccessFile("acc.dat", "rw");
         for (int i=0;i<100;i++)
         blank.write(file);
         System.exit(0);
    catch (IOException e )
         System.out.println("File doesn't exist");
         System.out.println("Invalid File Name");
         System.exit(1);     
    public static void main(String args[])
    JFrame tpo = new RandomTest();
    tpo.setTitle("Assignment 1");
    tpo.setSize(200,330);
    tpo.setVisible(true);
    tpo.createRandomFile();
    }     

  • Groups of small java codes

    Can any one help me where i will get very small java examples or codes to understand basic java api. Thank you very much for you help.

    http://javaboutique.internet.com/
    when i first started i found this site a immense help
    since i am one of those people who learn by doing
    not by falling asleep reading big articles and long winded books.
    thier is tutorials and stuff all over this site with small tutorials.
    best of all tons of programs and code for it that you can copy and paste or download in a zip file

  • A small Java Problem for java Experts

    Hi Guys...
    I have a small problem with my program...
    Tha program I am using consist of several frames where one invokes the other in row.
    These are the classes I am using:
    the FIRST class://THIS CLASS IS NOT COMPLETE
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    * LabelDemo.java is a 1.4 application that needs one other file:
    * images/middle.gif
    public class CSVloader extends JPanel implements ActionListener {
         ImageIcon icon ;
         JLabel label;
    JButton theButton1;
    JButton saveButton;
    JButton displayButton;
    JButton displayStyleButton;
    JFileChooser fc;
    final boolean shouldFill = true;
    final boolean shouldWeightX = true;
    public CSVloader() {
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(gridbag);
    if (shouldFill) {
    //natural height, maximum width
    c.fill = GridBagConstraints.HORIZONTAL;
    theButton1 = new JButton("Choose source File");
    theButton1.addActionListener(this);
    if (shouldWeightX) {
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 0;
    gridbag.setConstraints(theButton1, c);
    add(theButton1);
    displayStyleButton = new JButton("CSV Display style");
    displayStyleButton.addActionListener(this);
    c.gridx = 0;
    c.gridy = 2;
    gridbag.setConstraints(displayStyleButton, c);
    add(displayStyleButton);
    displayButton = new JButton("Display");
    displayButton.addActionListener(this);
    c.gridx = 1;
    c.gridy = 0;
    gridbag.setConstraints(displayButton, c);
    add(displayButton);
    saveButton = new JButton("Save");
    saveButton.addActionListener(this);
    c.gridx = 0;
    c.gridy = 1;
    gridbag.setConstraints(saveButton, c);
    add(saveButton);
    icon = new ImageIcon("c:/applets/CSVlogo.gif");
    //Create the first label.
    label = new JLabel(icon);
    c.ipady = 45; //make this component tall
    c.weightx = 0.0;
    c.gridwidth = 1;
    c.gridx = 1;
    c.gridy = 1;
    gridbag.setConstraints(label, c);
    add(label);
    fc = new JFileChooser();
    public Dimension getDimension(int hight, int width) {
    Dimension theDimension = new Dimension(hight,width);
    return theDimension;
    public void actionPerformed(ActionEvent e) {
    //Handle open button action.
    if (e.getSource() == theButton1) {
    int returnVal = fc.showOpenDialog(CSVloader.this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file = fc.getSelectedFile();
    //This is where a real application would open the file.
    //Handle save button action.
    } else
    if (e.getSource() == displayButton) {
         try {
    Runtime.getRuntime().exec("cmd /c start " + "c:\\applets\\displayData.html");
    catch(IOException io)
    System.err.println("Caught IOException: " +
         io.getMessage());
    }else
    if (e.getSource() == displayStyleButton)
    JFrame.setDefaultLookAndFeelDecorated(true);
    //Create and set up the window.
    JFrame frame = new JFrame("Display Style");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Create and set up the content pane.
    DisplayStyle newContentPane = new DisplayStyle();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    else
    if (e.getSource() == saveButton) {
         int returnVal = fc.showOpenDialog(CSVloader.this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
    File saveFile = fc.getSelectedFile();
    //This is where a real application would open the file.
    public static void main(String[] args) {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);
    //Create and set up the window.
    JFrame frame = new JFrame("LabelDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Create and set up the content pane.
    CSVloader newContentPane = new CSVloader();
    newContentPane.setBackground(Color.WHITE);
    newContentPane.setOpaque(true);
    frame.setContentPane(newContentPane);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    // Runtime.getRuntime().exec("cmd /c start " + "....\\docs\\index.html");
    this is the SECOND class:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DisplayStyle extends JPanel implements ActionListener{
         public static final int FIRST_OPTION = 0;
         public static final int SECOND_OPTION = 1;
         public static final int THIRD_OPTION = 2;
         public static final int THE_BUTTON_OPTION =3;
    public static final int ERROR = -1;
         public int selectedOption = ERROR;
         static String table = "Table";
         static String tableNoBorders = "Table without Borders";
         static String highlightedTable = "Highlighted Table without Borders";
         public JRadioButton theTable;
         public JRadioButton theTable2;
         public JRadioButton theTable3;
         public JButton theButton;
         public String theName;
         public DisplayStyle ()
         theTable = new JRadioButton(table);
         theTable.setActionCommand(""+ FIRST_OPTION);
         theTable.addActionListener(this);
         theTable.setMnemonic(KeyEvent.VK_B);     
    theTable.setSelected(true);
    theTable2 = new JRadioButton(tableNoBorders);
    theTable2.setActionCommand(""+ SECOND_OPTION);
         theTable2.addActionListener(this);
         theTable2.setMnemonic(KeyEvent.VK_B);     
    theTable3 = new JRadioButton(highlightedTable);
    theTable3.setActionCommand(""+ THIRD_OPTION);
         theTable3.addActionListener(this);
         theTable3.setMnemonic(KeyEvent.VK_B);     
    theButton = new JButton("OK");
    theButton.setActionCommand(""+ THE_BUTTON_OPTION);
    theButton.addActionListener(this);
         ButtonGroup group = new ButtonGroup();
    group.add(theTable);
    group.add(theTable2);
    group.add(theTable3);
    JLabel theLabel = new JLabel("Choose the style of Display");
    JPanel radioPanel = new JPanel(new GridLayout(0, 1));
    radioPanel.add(theLabel);
    radioPanel.add(theTable);
    radioPanel.add(theTable2);
    radioPanel.add(theTable3);
    radioPanel.add(theButton);
    add(radioPanel, BorderLayout.LINE_START);
         public void actionPerformed (ActionEvent e) {
         if(e.getSource() == theButton)
         JFrame.setDefaultLookAndFeelDecorated(true);
    //Create and set up the window.
    JFrame frame1 = new JFrame("The Format");
    frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Formats newFormat = new Formats();
    newFormat.setOpaque(true); //content panes must be opaque
    frame1.setContentPane(newFormat);
    //Display the window.
    frame1.pack();
    frame1.setVisible(true);
         selectedOption = Integer.parseInt(e.getActionCommand().trim());
         public DisplayStyle getInstance(){
              return this;      
    this is the THIRD class:
    mport java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Formats extends JPanel implements ActionListener{
         public static final int FIRST_OPTION = 0;
         public static final int SECOND_OPTION = 1;
         public static final int THIRD_OPTION = 2;
         public static final int FOURTH_OPTION = 4;
         public static final int THE_BUTTON_OPTION =3;
    public static final int ERROR = -1;
         public int selectedOption = ERROR;
         static String standardFormat = "Date first";
         static String timeFirstFormat = "Time First";
         static String typeFirstFormat = "Type of call first";
         static String extFirstFormat = "Extension first";
         public JButton theButton;
         public JRadioButton theStandardButton1 ;
         public JRadioButton theTimeButton;
         public JRadioButton theTypeButton;
         public JRadioButton theExtButton ;
         public Formats()
    theStandardButton1 = new JRadioButton(standardFormat);
         theStandardButton1.setMnemonic(KeyEvent.VK_B);     
    theStandardButton1.setSelected(true);
         theTimeButton = new JRadioButton(timeFirstFormat);
         theTimeButton.setMnemonic(KeyEvent.VK_B);     
    theTypeButton = new JRadioButton(typeFirstFormat);
         theTypeButton .setMnemonic(KeyEvent.VK_B);     
    theExtButton = new JRadioButton(extFirstFormat);
         theExtButton.setMnemonic(KeyEvent.VK_B);     
         ButtonGroup group = new ButtonGroup();
    group.add(theStandardButton1);
    group.add(theTimeButton);
    group.add(theTypeButton);
    group.add(theExtButton);
    JLabel newLabel = new JLabel("Choose the Format type for the data to be displayed");
    theButton = new JButton("OK");
    theButton.addActionListener(this);
    theButton.setActionCommand("" + THE_BUTTON_OPTION);
    JPanel radioPanel = new JPanel(new GridLayout(0, 1));
    radioPanel.add(newLabel);
    radioPanel.add(theStandardButton1);
    radioPanel.add(theTimeButton);
    radioPanel.add(theTypeButton);
    radioPanel.add(theExtButton);
    radioPanel.add(theButton);
    add(radioPanel, BorderLayout.LINE_START);      
         public void actionPerformed (ActionEvent e) {
         if(e.getSource() == theButton)
         JFrame.setDefaultLookAndFeelDecorated(true);
    //Create and set up the window.
    JFrame frame = new JFrame("The Font");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    TableFonts newFont = new TableFonts();
    newFont.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newFont);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
         selectedOption = Integer.parseInt(e.getActionCommand().trim());
         public Formats getInstance(){
              return this;      
    and the last class:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TableFonts extends JPanel implements ActionListener{
         static String standardFont = "Standard Font";
         static String boldFont = "Bold Font";
         static String italicFont = "Italic Font";
         static String monospaceFont = "Monospace Font";
         public      JRadioButton theStandardButton ;
         public JRadioButton theBoldButton;
         public JRadioButton theItalicButton;
         public JRadioButton theMonospaceButton ;
         public TableFonts()
    theStandardButton = new JRadioButton(standardFont);
         theStandardButton.setMnemonic(KeyEvent.VK_B);     
    theStandardButton.setSelected(true);
         theBoldButton = new JRadioButton(boldFont);
         theBoldButton.setMnemonic(KeyEvent.VK_B);     
    theItalicButton = new JRadioButton(italicFont);
         theItalicButton .setMnemonic(KeyEvent.VK_B);     
    theMonospaceButton = new JRadioButton(monospaceFont);
         theMonospaceButton.setMnemonic(KeyEvent.VK_B);     
         ButtonGroup group = new ButtonGroup();
    group.add(theStandardButton);
    group.add(theBoldButton);
    group.add(theItalicButton);
    group.add(theMonospaceButton);
    theStandardButton.addActionListener(this);
    theBoldButton.addActionListener(this);
    theItalicButton.addActionListener(this);
    theMonospaceButton.addActionListener(this);
    JLabel newLabel = new JLabel("Choose the correct font for the data to be displayed");
    JPanel radioPanel = new JPanel(new GridLayout(0, 1));
    radioPanel.add(newLabel);
    radioPanel.add(theStandardButton);
    radioPanel.add(theBoldButton);
    radioPanel.add(theItalicButton);
    radioPanel.add(theMonospaceButton);
    add(radioPanel, BorderLayout.LINE_START);
         public void actionPerformed(ActionEvent e) {
    The problem I am getting is the Number format exception when the OK button of the class Formats is clicked...
    here is the error I am getting:
    java.lang.NumberFormatException: For input string: "OK"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.
    java:48)
    at java.lang.Integer.parseInt(Integer.java:426)
    at java.lang.Integer.parseInt(Integer.java:476)
    at Formats.actionPerformed(Formats.java:80)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
    64)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
    ctButton.java:1817)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
    .java:419)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
    istener.java:245)
    at java.awt.Component.processMouseEvent(Component.java:5134)
    at java.awt.Component.processEvent(Component.java:4931)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3639)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3480)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
    at java.awt.Container.dispatchEventImpl(Container.java:1609)
    at java.awt.Window.dispatchEventImpl(Window.java:1590)
    at java.awt.Component.dispatchEvent(Component.java:3480)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
    read.java:197)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    ad.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
    COULD YOU GUYS PLEASE TELL ME HOW TO GET AROUND THIS PROBLEM:
    THANKS...

    It's in this line:
    selectedOption = Integer.parseInt(e.getActionCommand().trim());
    Kind regards,
      Levi
    PS. have you noticed the [code][code[i]] tags?

  • How to organize into smaller java files?

    I have a class which basically connects to a database and just about all of its methods query the database and return the results. The problem (which isn't actually a problem) is that the java file is getting so big because there are literally hundreds of methods representing different queries to the database.
    Does anyone has any idea how to break this class into smaller files? Is there a "include" statement of some sort that I can use to include these "sub-java" files?

    Does anyone has any idea how to break this class into smaller files? Is there a "include" statement of some sort that I can use to include these "sub-java" files?Different classes would still mean that user code would need to change.
    The problem (which isn't actually a problem) is that the java file is getting so big because there are literally hundreds of methods representing different queries to the database.Depending on how that is organized that isn't necessarily a problem. For instance if it did nothing but manage calls and not extraction then it isn't a terrible problem.
    If not then as previously suggested you break it by functional block. The closes model to what you have would be to break it into a class per each data model entity and then either add support classes for more complex support or add to one of the matching model entities.

  • Help find a small Java Opensource project

    Hi
    For an assignment in university I need to improve (i.e fix bugs and profiling) an existing java application. The application must be an opensource one and should contain 1000 - 1500 source lines of code. Please help me to find a suitable project.
    Cheers
    Lahiru

    I doubt you'll find much though that's that small. 1500 LOC is nothing, I doubt anyone would release his creation to the world until it was larger than that (unless maybe it were very trivial and complete by then).

  • Keep getting error message when trying out a small java program in terminal

    I've been trying out running java programs in mac os x terminal. I have eclipse as well, but it's too much for me right now. I copied some programs out of the dummies book I have, just to get a feel for things -- so, I went to the desktop where the program was, and compiled it (I saved it with a .java extension). "javac javaprogram.java" to compile, which it did fine, and then 'java javaprogram' to execute it. It's just a simple line that says 'you'll love java!'. Anyway, it wouldn't execute it.
    Here's the program (written in text edit):
    class Displayer {
         public static void main (String args []) {
              System.out.println ("You'll love Java!");
    I got these messages:
    Exception in thread "main" java.lang.NoClassDefFoundError: javaprogram
    Caused by: java.lang.ClassNotFoundException: javaprogram
         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:288)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
    Now, I noticed that the first part of the error is "java.lang.NoClassDefFoundError: javaprogram". When I tried to run the program, it 'created' or put something on the desktop called Displayer.class, so I'm not sure what's going on. I've compared what I entered to what's in the book, and there are no mistakes on my part.
    Can anyone tell me what I'm doing wrong, and is there any book or site I can go to which will instruct me on running programs in terminal?

    For starters, rename javaprogram.java to Displayer.java and dojavac Displayer.java
    java Displayerand since you are new to Java, change your source code to public class Displayer.
    In Java, files containing a Java class named "ClassName" should/have to be named "ClassName.java".

  • Open platform for developing small java applications  - Support platform.

    Hello everyone,
    The SAP NetWeaver Support Platform is an open platform to develop and run small utilities (known as plug-ins) that perform support oriented activities on any and all components of NetWeaver.
    I appreciate if you can take a few minutes to learn about the tool and provide your valuable feedback so we can design the next generation.
    Please follow this link to learn more:
    SAP NetWeaver Support Platform Feedback
    Thanks,
    Tal.

    Hello everyone,
    The SAP NetWeaver Support Platform is an open platform to develop and run small utilities (known as plug-ins) that perform support oriented activities on any and all components of NetWeaver.
    I appreciate if you can take a few minutes to learn about the tool and provide your valuable feedback so we can design the next generation.
    Please follow this link to learn more:
    SAP NetWeaver Support Platform Feedback
    Thanks,
    Tal.

  • Small java problem..

    hey
    I need to work out the smallest of three numbers entered:
    System.out.print("Please enter the red value ");
       redValue = Double.parseDouble(Keyboard.readLine());
       System.out.print("Please enter the green value ");
       greenValue = Double.parseDouble(Keyboard.readLine());
       System.out.print("Please enter the blue value ");
       blueValue = Double.parseDouble(Keyboard.readLine());how do i do it?? do i need to put it into an array or vector?

    Double lowest = redvalue;
    if(greenvalue < lowest)
         lowest = greenvalue
    if(bluevalue < lowest)
         lowest = bluevalue

  • Iam a novice using solaris 2.8 with labview 6.02. I am receiving the error me

    ssage "(HEX 0xBFFF003C) insufficient system resources to perform necessary memory allocation" message when attemping execution of a VI containing correctly wired visa Write and Read icons. Visa has identified the resource and through Ibic I can communicateI am getting the error code -1073807300

    ssage "(HEX 0xBFFF003C) insufficient system resources to perform necessary memory allocation" message when attemping execution of a VI containing correctly wired visa Write and Read icons. Visa has identified the resource and through Ibic I can communicateThank for the response. I am using a GPIB-ENET/100. The
    resource name used is "GIGA_8542" an alias for GPIB4::13::INSTR, the Gigatronics power meter at address 13 which is connected to the gpib-enet/100. I am making a *IDN? call to the device using a "VISA WRITE". There is a "VISA READ" configured for the test equipment response. The error code -1073807300 occurs at the output of the "VISA WRITE". Again Visa has identified the resource and through Ibic I can communicate. Thanks.

  • How to use java to create an XML document from an SQL database?

    Hi,
    I'm a complete novice at XML and have only recently started programming in Java.
    I'm currently trying to develop a package in Java 1.1.8 which requires a set of very specifically formatted XML documents. These documents would need to be updated regularly by people with no knowledge of Java and I would like to make it as simple as possible.
    Since the data will already be in an SQL database, I thought it might be possible to generate the XML documents from the data using a small Java application, but I'm not too sure how to go about this or if this is even possible! Any help or pointers in the right direction would be very much appreciated.
    Louise

    Do you have the option of upgrading to a newer version of the JDK?
    JAXB does what you are wanting very easily. Also there are tools if you don't want to write your own. JAXB is available as early release on Sun's site as is the newest JDK. Otherwise, you have to design a factory and interface that will do this for you (which is what JAXB basically is in a very simplified view).

  • Java arrays - flexible positioning of subscripting

    Hi, I am fairly familiar with Java so was surprised when I came across this line in HashTable.java:
    private transient Entry table[];
    I can find no reference to this sort of declaration of arrays in the array tutorial on the java.sun.com website. Does this mean that Java supports both this manner of creating arrays:
    int [] intArray;
    and this manner:
    int intArray [];
    I have tried both and they both compile using the Java 2 - 1.4.1 interpreter (i.e. using the javac command).
    Can anyone explain why Sun would support two different ways of declaring an array or is there a more logical explanation (i.e. that these two "intArray" variables are actually two different types of constructs)?
    Thanks,
    Novice

    >
    Well ... these are all valid declarations;-[snip]
    >
    They're all valid and on the whole java is consistent
    and logical, sorry if you find it confusing.
    [snip]
    I think you've misunderstood me. I did not say that Java is not consistent. I was simply trying to find a reason for the two different ways of declaring an array.
    I was just looking for a documented reason for supporting both as I'm modifying a Java grammar that supposedly conforms to the standard, but the grammar doesn't allow for this manner of array declaration.
    Thanks,
    Novice

  • Java Threads vs. Native Global Variables

    A brief description of the problem:
    I am trying to integrate a multi-threaded Java app with legacy Fortran code. The Fortran code in question makes extensive use of global variables in the form of Fortran's Common Block data structure.
    If multiple threads were allowed access to a native routine, they would over write each others data which is stored in global variables.
    If only one thread at a time can have access to the native routine for the duration of the native routine, the whole advantage of using threads is completely nullified.
    These native routines cannot be rewritten (3rd party code) and must be used.
    One solution I envisioned was to load a new copy of the native shared object code for each Java object that used the native code. However, it seems System.loadLibrary() can only be used in a static context.
    Is there any known solution to this problem?

    Here is an elaboration on the earlier suggestions. It's a high overhead solution, because you have to start a bunch of JVMs.
    1. You have a java control program, which will start up a pool of "services", make requests to them, and gather the results.
    2. Each service is a small java program with a native method:
    o java communications front-end.
    o native method declaration.
    o native - in your case fortran - method implementation.
    3. Each service is started using "exec". That puts it in a separate process.
    4, Since each service is a java program, you can use java to do communications between the control program and the service.
    o You could use RMI.
    o You could - perhaps - use java Process communications, i.e., have the services write to stdout, and have the control program capture the output.
    o You could use socket communications.

  • Java threads monitoring

    I am using Java threads in my Java program, running on Windows Professional 2000. I am monitoring the threads using Windows Performance Monitor (WPM). However, even running a small Java program which creates only 2 threads, results in many (at least 10) instances of Java threads being reported by the WPM. Problem is, in WPM, there is no way to determine which threads in the WPM are the threads that I programmatically created. Any ideas on how to determine this?
    Thanks.
    Rhodie

    Hi Dmirty ,
    To handle large asynchronous message   in queues you can use  message packaging where multiple message are processed in one package . to make it applicable you have to perform these simple steps
    1. go to SXMB_ADM add one RUNTIME parameter PACKAGING and value 1
    2 GO TO transaction SXMS_BCONF set delay time 0 message count 100 messages and package size 1000 KB
    with these setting your improvement will increase .secondly also put  IN SXMB_ADM monitor category parameter QRFC_RESTART_ALLOWED TO 1
    this will automatically start your queue . Only thing you have to take care if you enable packaging them don't keep too many parallel queue i.e EO_INBOUND_PARALLEL and EO_OUTBOUND_PARALLEL should be less than 20
    Regards,
    Saurabh

Maybe you are looking for

  • Backing up iTunes Library to New External Hard Drive

    I need to move the location of my itunes library as my external hard drive has become full. I have been backing up my "computer" (i.e. internal hard drive) and the itunes library stored on the external hard drive with TM. Once I move the library, I w

  • File transfer from old G4 iBook to new MacBook Pro

    I hope this is the right place for this post/question.... I am trying to do a file migration from my old iBook G4 PPC to my new MacBook Pro. The iBook does not have the migration utility and when I put the new OSX DVD in from my MacBook (as instructe

  • Obtaining FlexClient object in a filter

    Hi there, we have a special login routine which runs in a servlet filter above the blazeds Servlet. RPC calls are made via Remote Objects. We would like to switch to per client authentication but in the filter we do not have access to the client id o

  • Query Correction and Please Explan

    Dear Experts I have created a query to Sales Order ORDR and its Data from RDR1 and RDR1 and Connected it to Delievery ODLN. I want all the Sales Order irrespective of the Delievery is made or not. I some documents I am getting cartesian product. Plea

  • TS1702 Removal of apps.

    I cannot remove any apps from my iPad. I press and hold an icon, the icons all wiggle, and not one of them has an x in the corner. The x's disappeared a month or so ago, I thought I was doing something wrong, bu apparently not.