Trouble compiling code

I'm trying to write a rock, paper, scissors program but am having trouble converting an integer to its appropriate string. Here is the code I have:
// Rock.java
// Play Rock, Paper, Scissors with the user
import java.util.Scanner;
import java.util.Random;
public class Rock
public static void main(String[] args)
     String personPlay; //User's play -- "R", "P", or "S"
     String computerPlay; //Computer's play -- "R", "P", or "S"
     int computerInt; //Randomly generated number used to determine
     //computer's play
Scanner scan = new Scanner(System.in);
     Random generator = new Random();
     computerInt = generator.nextInt(3);//Generate computer's play (0,1,2)
     //Translate computer's randomly generated play to string
     switch (computerInt)
     case 0:
          System.out.println ("R");
          break;
     case 1:
          System.out.println ("P");
          break;
     case 2:
          System.out.println ("S");
          break;
System.out.println ("Enter your play: R, P, or S");//Get player's play from input-- note that this is stored as a string
personPlay = scan.nextLine();
personPlay = personPlay.toUpperCase();     //Make player's play uppercase for ease of comparison
System.out.println ("Computer play is " + computerPlay);     //Print computer's play
     //See who won. Use nested ifs instead of &&.
     if (personPlay.equals(computerPlay))
     System.out.println("It's a tie!");
     else
          if (personPlay.equals("R"))
               if (computerPlay.equals("S"))
               System.out.println("Rock crushes scissors. You win!!");
          if (computerPlay.equals("P"));
               System.out.println("Paper covers rock. You lose");
               if (personPlay.equals("P"))
                    if (computerPlay.equals("R"))
                    System.out.println("Paper covers rock. You win!!");
                    if (computerPlay.equals("S"))
                              System.out.println("Scissors cuts paper. You lose");
               if (personPlay.equals("S"))
                         if (computerPlay.equals("R"));
                                   System.out.println("Rock crushes scissors. You lose");
                         if (computerPlay.equals("P"))
                         System.out.println("Scissors cuts paper. You win!!");
          //... Fill in rest of code
My compiling error is that the string computerPlay was not initialized.. I think I need to do something more in the switch section of the code but can't figure out what. Thanks ahead of time for any advice!

soccer89 wrote:
My compiling error is that the string computerPlay was not initialized.. I think I need to do something more in the switch section of the code but can't figure out what. Thanks ahead of time for any advice!Instead of running System.out.println() set the value in your switch statementl then run
System.out.println(computerPlay);after it's properly set.
BTW, rather than a switch statement, you could use
computerPlay = "RPS".substring(computerInt, computerInt + 1);I'll leave you to work out why.
Winston

Similar Messages

  • Trouble Compiling my Email-client

    Hi
    I have written this email -client, but have some trouble compiling it !
    Then I try to compile it the following errors:
    MailClient.java:350: <identifier> expected
    public syncronize void mails(String t){
    ^
    MailClient.java:727: ';' expected
    private class myWindowListener extends WindowAdapter{
    ^
    MailClient.java:747: '}' expected
    3 errors.
    What do I need to change to correct these errors ?
    I hope that there is somebody out there who can help me get my program to work.
    Thanks in advance.
    Sincrely Yours
    Fred
    import java.io.*;
    import java.awt.*;
    import java.util.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    public class MailClient extends JFrame implements ActionListener{ 
    private Sendman mySendman;
    private Letterman myLetterman;
    public Writer myWrite;
    public Reader myReader;
    public Composer myComposer;
    private Setup mySetup;
    public Addressbook myAdressbook;
    private FixTask myFixTask;
    private Filter myFilter;
    private Info myInfo;
    public Vector mailIndexVector = new Vector();
    public Vector filterIndexVector = new Vector();
    public Vector folderVector = new Vector();
    private JPanel tArea, trae, icon, tField;
    private JTextArea ta;
    private JScrollPane view, treeScroll;
    private JTree tree;
    public JTextField tf;
    private JSplitPane split;
    private Dimension Size;
    private MailClient myMailClient;
    private String mailBody, subject, from;
    public boolean fromOutbox = false;
    public boolean viewSource = false;
    public static void main (String[] args) {
         MailClient myMailClient = new MailClient();
    public MailClient() {
         super("Mail-Client");
         ImageIcon linux = new ImageIcon("linux.gif");
         this.setIconImage(linux.getImage());
         icon = new JPanel();
         icon.setLayout(new FlowLayout(FlowLayout.LEFT));
         ImageIcon neu = new ImageIcon("getmail.gif");
         JButton neueMails = new JButton(neu);
         newMails.setActionCommand("Getting new Mails");
         newMails.addActionListener(this);
         newMails.setBorderPainted(false);
         newMails.setToolTipText("Getting new Mails");
         ImageIcon cr = new ImageIcon("creator.gif");
         JButton creator = new JButton(cr);
         creator.setActionCommand("Creator open");
         creator.addActionListener(this);
         creator.setBorderPainted(false);
         creator.setToolTipText("Creator open");
         JButton rep = new JButton(new ImageIcon("reply.gif"));
         rep.setActionCommand("rep");
         rep.addActionListener(this);
         rep.setBorderPainted(false);
         rep.setToolTipText("Reply");
         JButton fwd = new JButton(new ImageIcon("fwd.gif"));
         fwd.setActionCommand("fwd");
         fwd.addActionListener(this);
         fwd.setBorderPainted(false);
         fwd.setToolTipText("Forward");
         JButton ein = new JButton(new ImageIcon("settings.gif"));
         ein.setActionCommand("settings open");
         ein.addActionListener(this);
         ein.setBorderPainted(false);
    ein.setToolTipText("Setting open");
    JButton adr = new JButton(new ImageIcon("adressbook.gif"));
    adr.setActionCommand("adr");
    adr.addActionListener(this);
    adr.setBorderPainted(false);
    adr.setToolTipText("Addressbook");
    JButton lo = new JButton(new ImageIcon("trash.gif"));
    lo.setActionCommand("trash");
    lo.addActionListener(this);
    lo.setBorderPainted(false);
    lo.setToolTipText("trash");
    JButton in = new JButton(new ImageIcon("info.gif"));
    in.setActionCommand("Information");
    in.addActionListener(this);
    in.setBorderPainted(false);
    in.setToolTipText("Information");
    icon.add(newMails);
    icon.add(creator);
    icon.add(rep);
    icon.add(fwd);
    icon.add(set);
    icon.add(adr);
    icon.add(lo);
    icon.add(in);
    Vector h1 = myLeser.lese("Summary.4on");
    for(int i=0; i<h1.size(); i+=7){
    String id = h1.elementAt(i).toString();
    String fo = h1.elementAt(i+1).toString();
    String su = h1.elementAt(i+2).toString();
    String fr = h1.elementAt(i+3).toString();
    String to = h1.elementAt(i+4).toString();
    String da = h1.elementAt(i+5).toString();
    String re = h1.elementAt(i+6).toString();
    MailIndex index = new MailIndex(id, fo, su, fr, to, da, re);
    mailIndexVector.addElement(index);
    Vector h2 = myReader.read("Filter.4on");
    for(int j=0; j<h2.size(); j+=3){
    String fo = h2.elementAt(j).toString();
    String from = h2.elementAt(j+1).toString();
    String te = h2.elementAt(j+2).toString();
    FilterIndex index = new FilterIndex(fo, from, te);
    filterIndexVector.addElement(index);
    folderVector = myReader.read("Folder.4on");
    DefaultMutableTreeNode top, inbox, outbox, sentbox, trash;
    top = new DefaultMutableTreeNode("mails");
    top.add(inbox = new DefaultMutableTreeNode("Inbox"));
    for(int i=0; i<mailIndexVector.size(); i++){
    MailIndex m = (MailIndex)mailIndexVector.elementAt(i);
    if (m.folder.equals("Inbox"))
         inbox.add(new DefaultMutableTreeNode(m));
    top.add(outbox = new DefaultMutableTreeNode("Outbox"));
    for(int i=0; i<mailIndexVector.size(); i++){
    MailIndex m = (MailIndex)mailIndexVector.elementAt(i);
    if (m.folder.equals("Outbox")){
         outbox.add(new DefaultMutableTreeNode(m));
    top.add(sentbox = new DefaultMutableTreeNode("Sentbox"));
    for(int i=0; i<mailIndexVector.size(); i++){
    MailIndex m = (MailIndex)mailIndexVector.elementAt(i);
    if (m.folder.equals("Sentbox"))
         sentbox.add(new DefaultMutableTreeNode(m));
    for(int j=0; j<folderVector.size(); j++){
    top.add(trash =
         new DefaultMutableTreeNode(folderVector.elementAt(j).toString()));
    for(int i=0; i<mailIndexVector.size(); i++){
         MailIndex m = (MailIndex)mailIndexVector.elementAt(i);
         if (m.folder.equals(folderVector.elementAt(j).toString()))
         trash.add(new DefaultMutableTreeNode(m));
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode
    (TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.addTreeSelectionListener(new myTreeSelectionListener());
    treeScroll = new JScrollPane(tree);
    treeScroll.setFont(new Font("Monospaced",Font.PLAIN,6));
    baum.add("Center", treeScroll);
    MainMenu menuBar = new MainMenu(this, this);
    setJMenuBar(menuBar);
    setVisible(true);
    public void mailsFetcher() {
    myLetterman = new Letterman(this, mySetup);
    myLetterman.start();
    public void treeNewSign(){
    trae.remove(treeScroll);     
    DefaultMutableTreeNode top, inbox, outbox, sentbox, trash;
    top = new DefaultMutableTreeNode("mails");
    top.add(inbox = new DefaultMutableTreeNode("Inbox"));
    for(int i=0; i<mailIndexVector.size(); i++){
    MailIndex m = (MailIndex)mailIndexVector.elementAt(i);
    if (m.folder.equals("Inbox"))
         inbox.add(new DefaultMutableTreeNode(m));
    top.add(outbox = new DefaultMutableTreeNode("Outbox"));
    for(int i=0; i<mailIndexVector.size(); i++){
    MailIndex m = (MailIndex)mailIndexVector.elementAt(i);
    if (m.folder.equals("Outbox"))
         outbox.add(new DefaultMutableTreeNode(m));
    top.add(sentbox = new DefaultMutableTreeNode("Sentbox"));
    for(int i=0; i<mailIndexVector.size(); i++){
    MailIndex m = (MailIndex)mailIndexVector.elementAt(i);
    if (m.folder.equals("Sentbox"))
         sentbox.add(new DefaultMutableTreeNode(m));
    for(int j=0; j<folderVector.size(); j++){
    top.add(trash =
         new DefaultMutableTreeNode(folderVector.elementAt(j).toString()));
    for(int i=0; i<mailIndexVector.size(); i++){
         MailIndex m = (MailIndex)mailIndexVector.elementAt(i);
         if (m.folder.equals(folderVector.elementAt(j).toString()))
         trash.add(new DefaultMutableTreeNode(m));
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode
    (TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.addTreeSelectionListener(new myTreeSelectionListener());
    treeScroll = new JScrollPane(tree);
    trae.add("Center", treeScroll);
    trae.repaint();
    setVisible(true);
    public void menuNewSign(){
    setJMenuBar(new MainMenu(this, this));
    setVisible(true);
    public String fromFilter (String t){
    String myFrom = "";
    int start, end;
    int a = t.indexOf("From:");
    if (a != -1){
    start = a + 6;
    ende = t.indexOf("\n",start);
    myFrom = t.substring(start,end);
    return myFrom;
    public String toFilter (String t){
    String myTo = "";
    int start, e1, e2, end;
    int a = t.indexOf("To:");
    if (a != -1){
    start = a + 4;
    end = t.indexOf("\n",start);
    myTo = t.substring(start,end);
    e1 = end + 1;
    if(t.substring(e1,e1+1).equals(" ")){
         while(t.substring(e1,e1+1).equals(" ")){
         while(t.substring(e1,e1+1).equals(" "))
         e1++;
         e2 = t.indexOf("\n",e1);
         myTo += " " + t.substring(e1,e2);
         e1 = e2 + 1;
    return myTo;
    public String dateFilter (String t){
    String myDate = "";
    int start, end;
    int a = t.indexOf("Date:");
    if (a != -1){
    start = a + 6;
    end = t.indexOf("\n",start);
    myDate = t.substring(start,end);
    return myDate;
    public String subjectFilter (String t){
    String mySubject = "";
    int start, end;
    int a = t.indexOf("Subject:");
    if (a != -1){
    start = a + 9;
    end = t.indexOf("\n",start);
    mySubject = t.substring(start,end);
    return mySubject;
    public String mailFilter (String t){ 
    String myMail = "";
    int start = 0, end = t.length();
    start = t.indexOf("\n\n") + 2;
    if (start != 1){
    int a = t.indexOf("\n\n" ,start);
    if (a != -1){
         if (t.indexOf(".",a+2) == a+2)
         if (t.indexOf("\n",a+3) == a+3)
         start = a;
    myMail = t.substring(start,end);
    return myMail;
    public void mailsRemark(String file){
    String mail = "", t = "";
    Vector mailVector = myReader.read(file);
    for (int i=0; i<mailVector.size(); i++)
    t += (String)mailVector.elementAt(i) + "\n";
    from = fromFilter(t);
    subject = subjectFilter(t);
    mailBody = mailFilter(t);
    mail += "Subject: " + subject + "\n";
    mail += "Date: " + dateFilter(t) + "\n";
    mail += "From: " + from + "\n";
    mail += "To: " + toFilter(t) + "\n";
    mail += "\n" + mailBody;
    if(viewSource == true)
    ta.setText(t);
    else
    ta.setText(mail);
    public syncronize void mails(String t){
    Status myStatus = new Status(this,t);
    myStatus.start();
    public void delete(){
    if(tree.getLastSelectedPathComponent() != null){
    DefaultMutableTreeNode node =
         (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
    if(node.isLeaf()){
         Object nodeInfo = node.getUserObject();
         if(nodeInfo instanceof MailIndex){
         MailIndex index = (MailIndex)nodeInfo;
         mailIndexVector.removeElement(index);
         int count = 0;
         for(int j=0; j<mailIndexVector.size(); j++){
         MailIndex index1 = (MailIndex)mailIndexVector.elementAt(j);
         String id = index1.mailId;
         if(id.equals(index.mailId))
         count++;
         if(count == 0){
         File home = new File(".");
         String mailsRemark = "." + home.separator + "data";
         File datei = new File(mailsRemark, index.mailId);
         datei.delete();
         treeNewSign();
         menuNewSign();
         else{
         String t = (String)nodeInfo;
         boolean toDelete = false;
         for (int i=0; i<folderVector.size(); i++){
         if(folderVector.elementAt(i).equals(t)){
         folderVector.removeElement(t);
         konnteLoeschen = true;
         if(toDelete == false){
         message("This folder can not be deleted!");
         treeNewSign();
    else
         message("Folder is not Empty! Please delete Your mails.");
    else
    message("No Mails where selected to be deleted!");
    public void forward(){
    if(from != null){
    creatorOeffnen();
    myCreator.tfSb.setText("Fwd to: " + subject);
    myCreator.ta.setText("<" + from + ">" + " wrote:\n\n" + mailBody +
                   "\n\n>\n>\n\n");
    public void reply(){
    if(from != null){
    creatorOeffnen();
    myCreator.tfTo.setText(from);
    myCreator.tfSb.setText("Reply to: " + subject);
    myCreator.ta.setText("<" + from + ">" + " wrote:\n\n" + mailBody +
                   "\n\n>\n>\n\n");
    public void end(){
    String h = "";
    for (int i=0; i<mailIndexVector.size(); i++){
    MailIndex index = (MailIndex)mailIndexVector.elementAt(i);
    h += index.mailId + "\n";
    h += index.folder + "\n";
    h += index.subject + "\n";
    h += index.from + "\n";
    h += index.to + "\n";
    h += index.date + "\n";
    h += index.read + "\n";
    myWriter.writer(h,"Summary.4on");
    String w = "";
    for (int l=0; l<filterIndexVector.size(); l++){
    FilterIndex index = (FilterIndex)filterIndexVector.elementAt(l);
    w += index.folder + "\n";
    w += index.from + "\n";
    w += index.text + "\n";
    myWriter.write(w,"Filter.4on");
    String k = "";
    for(int j=0; j<folderVector.size(); j++)
    k += folderVector.elementAt(j).toString() + "\n";
    myWriter.writer(k,"Folder.4on");
    String t = "";
    for (int l=0; l<myAddressBook.addressIndexVector.size(); l++){
    AddressIndex aindex =
         (AddressIndex)myAdressBook.adressIndexVector.elementAt(l);
    t += aindex.alias + "\n";
    t += aindex.email + "\n";
    myWriter.write(t,"Address.4on");
    setVisible(false);
    dispose();
    System.exit(0);
    public void filterOpen(){
    boolean test = false;
    if(tree.getLastSelectedPathComponent() != null){
    DefaultMutableTreeNode node =
         (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
    Object nodeInfo = node.getUserObject();
    if(nodeInfo instanceof String){
         myFilter.folder = (String)nodeInfo;
         for(int i=0; i<filterIndexVector.size(); i++){
         FilterIndex h = (FilterIndex)filterIndexVector.elementAt(i);
         if(h.folder.equals(nodeInfo)){
         myFilter.index = h;
         test = true;
         if(h.from.equals("")){
         myFilter.box1 = false;
         myFilter.fTf.setText("");
         myFilter.fBox.setSelected(false);
         myFilter.fTf.setEditable(false);
         else{
         myFilter.box1 = true;
         myFilter.fTf.setText(h.from);
         myFilter.fBox.setSelected(true);
         myFilter.fTf.setEditable(true);
         if(h.text.equals("")){
         myFilter.box2 = false;
         myFilter.tTf.setText("");
         myFilter.tBox.setSelected(false);
         myFilter.tTf.setEditable(false);
         else{
         myFilter.box2 = true;
         myFilter.tTf.setText(h.text);
         myFilter.tBox.setSelected(true);
         myFilter.tTf.setEditable(true);
         break;
    myFilter.setVisible(true);
    myFilter.fBox.requestFocus();
    else
    meldung("No selection");
    public void sendOutbox(){
    fromOutbox = true;
    int i;
    Block1:
    for(i=0; i<mailIndexVector.size(); i++){
    MailIndex index = (MailIndex)mailIndexVector.elementAt(i);
    if(index.folder.equals("Outbox")){
         Vector mailVector = myReader.read(index.mailId);
    Block2:
         for(int j=0; j<mailVector.size(); j++){
         String m = (String)mailVector.elementAt(j);
         if(m.indexOf("Subject:") != -1){
         for(int k=0; k<=j+1; k++){
         mailVector.removeElementAt(0);
         break Block2;
         Vector toVector = new Vector();
         int tEnd = 1;
         String line = "";
         String t = index.to;
         while (tEnd != -1){
         tEnd = t.indexOf(", ");
         if (tEnd == -1)
         line = t;
         else
         line = t.substring(0,tEnd);
         t = t.substring(tEnd + 1);
         toVector.addElement(line);
         File home = new File(".");
         String mailsVerzeichnis = "." + home.separator + "data";
         File datei = new File(mailsRemark, index.mailId);
         datei.delete();
         mySendman = new Sendman(mailVector, toVector, index.subject,
         ailsAnzeig               mySetup, this);
         mySendman.start();
         mailIndexVector.removeElement(index);
         break Block1;
    if(i == mailIndexVector.size())
    fromOutbox = false;
    treeNewSign();
    public void partion(String cmd){
    if(tree.getLastSelectedPathComponent() != null){
    DefaultMutableTreeNode node =
         (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
    Object nodeInfo = node.getUserObject();
    if(nodeInfo instanceof MailIndex){
         MailIndex index = (MailIndex)nodeInfo;
         index.folder = cmd.substring(13).toString();
         treeNewSign();
    else
    meldung("No mails to partion!");
    public void SetupOpen(){
    if (mySetup.savePassword == false)
    mySetup.pTf.setText("");
    mySetup.setVisible(true);
    mySetup.aTf.requestFocus();
    public void addressbookOpen(){
    myAddressBook.setVisible(true);
    myAdressBook.tree.requestFocus();
    public void creatorOpen(){
    myCreator.setVisible(true);
    myCreator.tfTo.requestFocus();
    public void actionPerformed(ActionEvent event){
    Object obj = event.getSource();
    if (obj instanceof JMenuItem){
    String cmd = event.getActionCommand();
    if (cmd.equals("New fetched")){
         mailsfetch();
    else if (cmd.equals("Written new mails")) {
         creatorOpen();
    else if (cmd.equals("Reply")) {
         reply();
    else if (cmd.equals("Forward")) {
         forward();
    else if (cmd.equals("Outbox")) {
         sendOutbox();
    else if (cmd.equals("Delete")) {
         delete();
    else if ((cmd.length() >13) &&
         (cmd.substring(0,13).equals("Sorting-"))){
         sorting(cmd);
    else if (cmd.equals("Using Addressbook")){
         addressbookOpen();
    else if (cmd.equals("Filter working")){
         filterOpen();
    else if (cmd.equals("New Order")){
         myFixTask.tf.setText("");
         myFixTask.setVisible(true);
         myFixTask.tf.requestFocus();
    else if (cmd.equals("delete")){
         delete();
    else if ((cmd.length() >7) &&
         (cmd.substring(0,7).equals("nobody"))){
         if(viewSource == false){
         viewSource = true;
         menuNewSign();
         if(tree.getLastSelectedPathComponent() != null){
         DefaultMutableTreeNode node =
         (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
         Object nodeInfo = node.getUserObject();
         if(nodeInfo instanceof MailIndex){
         MailIndex index = (MailIndex)nodeInfo;
         mailsRemark(index.mailId);
         else{
         viewSource = false;
         menuNeuZeichnen();
         if(tree.getLastSelectedPathComponent() != null){
         DefaultMutableTreeNode node =
         (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
         Object nodeInfo = node.getUserObject();
         if(nodeInfo instanceof MailIndex){
         MailIndex index = (MailIndex)nodeInfo;
         mailsRemark(index.mailId);
    else if (cmd.equals("Setup")){
         SetupOpen();
    else if (obj instanceof JButton){
    String cmd = event.getActionCommand();
    if (cmd.equals("aga")){
         mailsHolen();
    else if (cmd.equals("Creator Open")){
         creatorOpem();
    else if(cmd.equals("rep")){
         reply();
    else if(cmd.equals("fwd")){
         forward();
    else if(cmd.equals("Setup Open")){
    SetupOpen();
    else if(cmd.equals("adr")){
         addressbookOpen();
    else if(cmd.equals("delete")){
         delete();
    else if(cmd.equals("Information")){
         myInfo.setVisible(true);
         myInfo.b.requestFocus();
    private class myWindowListener extends WindowAdapter{
    public void windowClosing(WindowEvent event){
    end();
    private class myTreeSelectionListener implements TreeSelectionListener{
    public void valueChanged(TreeSelectionEvent e) {
    DefaultMutableTreeNode node =
         (DefaultMutableTreeNode)(e.getPath().getLastPathComponent());
    Object nodeInfo = node.getUserObject();
    if(nodeInfo instanceof MailIndex){
         MailIndex index = (MailIndex)nodeInfo;
         mailsAnzeigen(index.mailId);
         index.read = "Yes";

    Some suggestions:
    1. as the others stated- you should really post specific questions rather than 1 huge ugly class!
    2. use code tags
    3. get a decent IDE- it would take about 1 minute to then see where the error is-
    4. the rrors were just misspelled 'synchronized' and missing argument ','
    5. Try not to make such huge classes!!- Try to follow certain coding "patterns"- like MVC- and not stick everything in 1 class- separate the functionality- it makes coding much easier!
    here is fixed code (at least gets rid of those last errors):
    import java.io.*;
    import java.awt.*;
    import java.util.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    public class MailClient extends JFrame implements ActionListener{
      private Sendman mySendman;
      private Letterman myLetterman;
      public Writer myWrite;
      public Reader myReader;
      public Composer myComposer;
      private Setup mySetup;
      public Addressbook myAdressbook;
      private FixTask myFixTask;
      private Filter myFilter;
      private Info myInfo;
      public Vector mailIndexVector = new Vector();
      public Vector filterIndexVector = new Vector();
      public Vector folderVector = new Vector();
      private JPanel tArea, trae, icon, tField;
      private JTextArea ta;
      private JScrollPane view, treeScroll;
      private JTree tree;
      public JTextField tf;
      private JSplitPane split;
      private Dimension Size;
      private MailClient myMailClient;
      private String mailBody, subject, from;
      public boolean fromOutbox = false;
      public boolean viewSource = false;
      public static void main (String[] args) {
        MailClient myMailClient = new MailClient();
      public MailClient() {
        super("Mail-Client");
        ImageIcon linux = new ImageIcon("linux.gif");
        this.setIconImage(linux.getImage());
        icon = new JPanel();
        icon.setLayout(new FlowLayout(FlowLayout.LEFT));
        ImageIcon neu = new ImageIcon("getmail.gif");
        JButton neueMails = new JButton(neu);
        newMails.setActionCommand("Getting new Mails");
        newMails.addActionListener(this);
        newMails.setBorderPainted(false);
        newMails.setToolTipText("Getting new Mails");
        ImageIcon cr = new ImageIcon("creator.gif");
        JButton creator = new JButton(cr);
        creator.setActionCommand("Creator open");
        creator.addActionListener(this);
        creator.setBorderPainted(false);
        creator.setToolTipText("Creator open");
        JButton rep = new JButton(new ImageIcon("reply.gif"));
        rep.setActionCommand("rep");
        rep.addActionListener(this);
        rep.setBorderPainted(false);
        rep.setToolTipText("Reply");
        JButton fwd = new JButton(new ImageIcon("fwd.gif"));
        fwd.setActionCommand("fwd");
        fwd.addActionListener(this);
        fwd.setBorderPainted(false);
        fwd.setToolTipText("Forward");
        JButton ein = new JButton(new ImageIcon("settings.gif"));
        ein.setActionCommand("settings open");
        ein.addActionListener(this);
        ein.setBorderPainted(false);
        ein.setToolTipText("Setting open");
        JButton adr = new JButton(new ImageIcon("adressbook.gif"));
        adr.setActionCommand("adr");
        adr.addActionListener(this);
        adr.setBorderPainted(false);
        adr.setToolTipText("Addressbook");
        JButton lo = new JButton(new ImageIcon("trash.gif"));
        lo.setActionCommand("trash");
        lo.addActionListener(this);
        lo.setBorderPainted(false);
        lo.setToolTipText("trash");
        JButton in = new JButton(new ImageIcon("info.gif"));
        in.setActionCommand("Information");
        in.addActionListener(this);
        in.setBorderPainted(false);
        in.setToolTipText("Information");
        icon.add(newMails);
        icon.add(creator);
        icon.add(rep);
        icon.add(fwd);
        icon.add(set);
        icon.add(adr);
        icon.add(lo);
        icon.add(in);
        Vector h1 = myLeser.lese("Summary.4on");
        for(int i=0; i<h1.size(); i+=7){
          String id = h1.elementAt(i).toString();
          String fo = h1.elementAt(i+1).toString();
          String su = h1.elementAt(i+2).toString();
          String fr = h1.elementAt(i+3).toString();
          String to = h1.elementAt(i+4).toString();
          String da = h1.elementAt(i+5).toString();
          String re = h1.elementAt(i+6).toString();
          MailIndex index = new MailIndex(id, fo, su, fr, to, da, re);
          mailIndexVector.addElement(index);
        Vector h2 = myReader.read("Filter.4on");
        for(int j=0; j<h2.size(); j+=3){
          String fo = h2.elementAt(j).toString();
          String from = h2.elementAt(j+1).toString();
          String te = h2.elementAt(j+2).toString();
          FilterIndex index = new FilterIndex(fo, from, te);
          filterIndexVector.addElement(index);
        folderVector = myReader.read("Folder.4on");
        DefaultMutableTreeNode top, inbox, outbox, sentbox, trash;
        top = new DefaultMutableTreeNode("mails");
        top.add(inbox = new DefaultMutableTreeNode("Inbox"));
        for(int i=0; i<mailIndexVector.size(); i++){
          MailIndex m = (MailIndex)mailIndexVector.elementAt(i);
          if (m.folder.equals("Inbox"))
            inbox.add(new DefaultMutableTreeNode(m));
        top.add(outbox = new DefaultMutableTreeNode("Outbox"));
        for(int i=0; i<mailIndexVector.size(); i++){
          MailIndex m = (MailIndex)mailIndexVector.elementAt(i);
          if (m.folder.equals("Outbox")){
            outbox.add(new DefaultMutableTreeNode(m));
        top.add(sentbox = new DefaultMutableTreeNode("Sentbox"));
        for(int i=0; i<mailIndexVector.size(); i++){
          MailIndex m = (MailIndex)mailIndexVector.elementAt(i);
          if (m.folder.equals("Sentbox"))
            sentbox.add(new DefaultMutableTreeNode(m));
        for(int j=0; j<folderVector.size(); j++){
          top.add(trash =
          new DefaultMutableTreeNode(folderVector.elementAt(j).toString()));
          for(int i=0; i<mailIndexVector.size(); i++){
            MailIndex m = (MailIndex)mailIndexVector.elementAt(i);
            if (m.folder.equals(folderVector.elementAt(j).toString()))
              trash.add(new DefaultMutableTreeNode(m));
        tree = new JTree(top);
        tree.getSelectionModel().setSelectionMode
        (TreeSelectionModel.SINGLE_TREE_SELECTION);
        tree.addTreeSelectionListener(new myTreeSelectionListener());
        treeScroll = new JScrollPane(tree);
        treeScroll.setFont(new Font("Monospaced",Font.PLAIN,6));
        baum.add("Center", treeScroll);
        MainMenu menuBar = new MainMenu(this, this);
        setJMenuBar(menuBar);
        setVisible(true);
      public void mailsFetcher() {
        myLetterman = new Letterman(this, mySetup);
        myLetterman.start();
      public void treeNewSign(){
        trae.remove(treeScroll);
        DefaultMutableTreeNode top, inbox, outbox, sentbox, trash;
        top = new DefaultMutableTreeNode("mails");
        top.add(inbox = new DefaultMutableTreeNode("Inbox"));
        for(int i=0; i<mailIndexVector.size(); i++){
          MailIndex m = (MailIndex)mailIndexVector.elementAt(i);
          if (m.folder.equals("Inbox"))
            inbox.add(new DefaultMutableTreeNode(m));
        top.add(outbox = new DefaultMutableTreeNode("Outbox"));
        for(int i=0; i<mailIndexVector.size(); i++){
          MailIndex m = (MailIndex)mailIndexVector.elementAt(i);
          if (m.folder.equals("Outbox"))
            outbox.add(new DefaultMutableTreeNode(m));
        top.add(sentbox = new DefaultMutableTreeNode("Sentbox"));
        for(int i=0; i<mailIndexVector.size(); i++){
          MailIndex m = (MailIndex)mailIndexVector.elementAt(i);
          if (m.folder.equals("Sentbox"))
            sentbox.add(new DefaultMutableTreeNode(m));
        for(int j=0; j<folderVector.size(); j++){
          top.add(trash =
          new DefaultMutableTreeNode(folderVector.elementAt(j).toString()));
          for(int i=0; i<mailIndexVector.size(); i++){
            MailIndex m = (MailIndex)mailIndexVector.elementAt(i);
            if (m.folder.equals(folderVector.elementAt(j).toString()))
              trash.add(new DefaultMutableTreeNode(m));
        tree = new JTree(top);
        tree.getSelectionModel().setSelectionMode
        (TreeSelectionModel.SINGLE_TREE_SELECTION);
        tree.addTreeSelectionListener(new myTreeSelectionListener());
        treeScroll = new JScrollPane(tree);
        trae.add("Center", treeScroll);
        trae.repaint();
        setVisible(true);
      public void menuNewSign(){
        setJMenuBar(new MainMenu(this, this));
        setVisible(true);
      public String fromFilter (String t){
        String myFrom = "";
        int start, end;
        int a = t.indexOf("From:");
        if (a != -1){
          start = a + 6;
          ende = t.indexOf("\n",start);
          myFrom = t.substring(start,end);
        return myFrom;
      public String toFilter (String t){
        String myTo = "";
        int start, e1, e2, end;
        int a = t.indexOf("To:");
        if (a != -1){
          start = a + 4;
          end = t.indexOf("\n",start);
          myTo = t.substring(start,end);
          e1 = end + 1;
          if(t.substring(e1,e1+1).equals(" ")){
            while(t.substring(e1,e1+1).equals(" ")){
              while(t.substring(e1,e1+1).equals(" "))
                e1++;
              e2 = t.indexOf("\n",e1);
              myTo += " " + t.substring(e1,e2);
              e1 = e2 + 1;
        return myTo;
      public String dateFilter (String t){
        String myDate = "";
        int start, end;
        int a = t.indexOf("Date:");
        if (a != -1){
          start = a + 6;
          end = t.indexOf("\n",start);
          myDate = t.substring(start,end);
        return myDate;
      public String subjectFilter (String t){
        String mySubject = "";
        int start, end;
        int a = t.indexOf("Subject:");
        if (a != -1){
          start = a + 9;
          end = t.indexOf("\n",start);
          mySubject = t.substring(start,end);
        return mySubject;
      public String mailFilter (String t){
        String myMail = "";
        int start = 0, end = t.length();
        start = t.indexOf("\n\n") + 2;
        if (start != 1){
          int a = t.indexOf("\n\n" ,start);
          if (a != -1){
            if (t.indexOf(".",a+2) == a+2)
              if (t.indexOf("\n",a+3) == a+3)
                start = a;
          myMail = t.substring(start,end);
        return myMail;
      public void mailsRemark(String file){
        String mail = "", t = "";
        Vector mailVector = myReader.read(file);
        for (int i=0; i<mailVector.size(); i++)
          t += (String)mailVector.elementAt(i) + "\n";
        from = fromFilter(t);
        subject = subjectFilter(t);
        mailBody = mailFilter(t);
        mail += "Subject: " + subject + "\n";
        mail += "Date: " + dateFilter(t) + "\n";
        mail += "From: " + from + "\n";
        mail += "To: " + toFilter(t) + "\n";
        mail += "\n" + mailBody;
        if(viewSource == true)
          ta.setText(t);
        else
          ta.setText(mail);
      public synchronized void mails(String t){
        Status myStatus = new Status(this,t);
        myStatus.start();
      public void delete(){
        if(tree.getLastSelectedPathComponent() != null){
          DefaultMutableTreeNode node =
              (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
          if(node.isLeaf()){
            Object nodeInfo = node.getUserObject();
            if(nodeInfo instanceof MailIndex){
              MailIndex index = (MailIndex)nodeInfo;
              mailIndexVector.removeElement(index);
              int count = 0;
              for(int j=0; j<mailIndexVector.size(); j++){
                MailIndex index1 = (MailIndex)mailIndexVector.elementAt(j);
                String id = index1.mailId;
                if(id.equals(index.mailId))
                  count++;
              if(count == 0){
                File home = new File(".");
                String mailsRemark = "." + home.separator + "data";
                File datei = new File(mailsRemark, index.mailId);
                datei.delete();
              treeNewSign();
              menuNewSign();
            else{
              String t = (String)nodeInfo;
              boolean toDelete = false;
              for (int i=0; i<folderVector.size(); i++){
                if(folderVector.elementAt(i).equals(t)){
                  folderVector.removeElement(t);
                  konnteLoeschen = true;
              if(toDelete == false){
                message("This folder can not be deleted!");
              treeNewSign();
          else
            message("Folder is not Empty! Please delete Your mails.");
        else
          message("No Mails where selected to be deleted!");
      public void forward(){
        if(from != null){
          creatorOeffnen();
          myCreator.tfSb.setText("Fwd to: " + subject);
          myCreator.ta.setText("<" + from + ">" + " wrote:\n\n" + mailBody +
                               "\n\n>\n>\n\n");
      public void reply(){
        if(from != null){
          creatorOeffnen();
          myCreator.tfTo.setText(from);
          myCreator.tfSb.setText("Reply to: " + subject);
          myCreator.ta.setText("<" + from + ">" + " wrote:\n\n" + mailBody +
                               "\n\n>\n>\n\n");
      public void end(){
        String h = "";
        for (int i=0; i<mailIndexVector.size(); i++){
          MailIndex index = (MailIndex)mailIndexVector.elementAt(i);
          h += index.mailId + "\n";
          h += index.folder + "\n";
          h += index.subject + "\n";
          h += index.from + "\n";
          h += index.to + "\n";
          h += index.date + "\n";
          h += index.read + "\n";
        myWriter.writer(h,"Summary.4on");
        String w = "";
        for (int l=0; l<filterIndexVector.size(); l++){
          FilterIndex index = (FilterIndex)filterIndexVector.elementAt(l);
          w += index.folder + "\n";
          w += index.from + "\n";
          w += index.text + "\n";
        myWriter.write(w,"Filter.4on");
        String k = "";
        for(int j=0; j<folderVector.size(); j++)
          k += folderVector.elementAt(j).toString() + "\n";
        myWriter.writer(k,"Folder.4on");
        String t = "";
        for (int l=0; l<myAddressBook.addressIndexVector.size(); l++){
          AddressIndex aindex =
                   (AddressIndex)myAdressBook.adressIndexVector.elementAt(l);
          t += aindex.alias + "\n";
          t += aindex.email + "\n";
        myWriter.write(t,"Address.4on");
        setVisible(false);
        dispose();
        System.exit(0);
      public void filterOpen(){
        boolean test = false;
        if(tree.getLastSelectedPathComponent() != null){
          DefaultMutableTreeNode node =
              (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
          Object nodeInfo = node.getUserObject();
          if(nodeInfo instanceof String){
            myFilter.folder = (String)nodeInfo;
            for(int i=0; i<filterIndexVector.size(); i++){
              FilterIndex h = (FilterIndex)filterIndexVector.elementAt(i);
              if(h.folder.equals(nodeInfo)){
                myFilter.index = h;
                test = true;
                if(h.from.equals("")){
                  myFilter.box1 = false;
                  myFilter.fTf.setText("");
                  myFilter.fBox.setSelected(false);
                  myFilter.fTf.setEditable(false);
                else{
                  myFilter.box1 = true;
                  myFilter.fTf.setText(h.from);
                  myFilter.fBox.setSelected(true);
                  myFilter.fTf.setEditable(true);
                if(h.text.equals("")){
                  myFilter.box2 = false;
                  myFilter.tTf.setText("");
                  myFilter.tBox.setSelected(false);
                  myFilter.tTf.setEditable(false);
                else{
                  myFilter.box2 = true;
                  myFilter.tTf.setText(h.text);
                  myFilter.tBox.setSelected(true);
                  myFilter.tTf.setEditable(true);
                break;
          myFilter.setVisible(true);
          myFilter.fBox.requestFocus();
        else
          meldung("No selection");
      public void sendOutbox(){
        fromOutbox = true;
        int i;
        Block1:
        for(i=0; i<mailIndexVector.size(); i++){
          MailIndex index = (MailIndex)mailIndexVector.elementAt(i);
          if(index.folder.equals("Outbox")){
            Vector mailVector = myReader.read(index.mailId);
            Block2:
            for(int j=0; j<mailVector.size(); j++){
              String m = (String)mailVector.elementAt(j);
              if(m.indexOf("Subject:") != -1){
                for(int k=0; k<=j+1; k++){
                  mailVector.removeElementAt(0);
                break Block2;
            Vector toVector = new Vector();
            int tEnd = 1;
            String line = "";
            String t = index.to;
            while (tEnd != -1){
              tEnd = t.indexOf(", ");
              if (tEnd == -1)
                line = t;
              else
                line = t.substring(0,tEnd);
              t = t.substring(tEnd + 1);
              toVector.addElement(line);
            File home = new File(".");
            String mailsVerzeichnis = "." + home.separator + "data";
            File datei = new File(mailsRemark, index.mailId);
            datei.delete();
            mySendman = new Sendman(mailVector, toVector, index.subject,ailsAnzeig, mySetup, this);
            mySendman.start();
            mailIndexVector.removeElement(index);
            break Block1;
        if(i == mailIndexVector.size())
          fromOutbox = false;
        treeNewSign();
      public void partion(String cmd){
        if(tree.getLastSelectedPathComponent() != null){
          DefaultMutableTreeNode node =
              (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
          Object nodeInfo = node.getUserObject();
          if(nodeInfo instanceof MailIndex){
            MailIndex index = (MailIndex)nodeInfo;
            index.folder = cmd.substring(13).toString();
            treeNewSign();
        else
          meldung("No mails to partion!");
      public void SetupOpen(){
        if (mySetup.savePassword == false)
          mySetup.pTf.setText("");
        mySetup.setVisible(true);
        mySetup.aTf.requestFocus();
      public void addressbookOpen(){
        myAddressBook.setVisible(true);
        myAdressBook.tree.requestFocus();
      public void creatorOpen(){
        myCreator.setVisible(true);
        myCreator.tfTo.requestFocus();
      public void actionPerformed(ActionEvent event){
        Object obj = event.getSource();
        if (obj instanceof JMenuItem){
          String cmd = event.getActionCommand();
          if (cmd.equals("New fetched")){
            mailsfetch();
          else if (cmd.equals("Written new mails")) {
            creatorOpen();
          else if (cmd.equals("Reply")) {
            reply();
          else if (cmd.equals("Forward")) {
            forward();
          else if (cmd.equals("Outbox")) {
            sendOutbox();
          else if (cmd.equals("Delete")) {
            delete();
          else if ((cmd.length() >13) &&
                   (cmd.substring(0,13).equals("Sorting-"))){
            sorting(cmd);
          else if (cmd.equals("Using Addressbook")){
            addressbookOpen();
          else if (cmd.equals("Filter working")){
            filterOpen();
          else if (cmd.equals("New Order")){
            myFixTask.tf.setText("");
            myFixTask.setVisible(true);
            myFixTask.tf.requestFocus();
          else if (cmd.equals("delete")){
            delete();
          else if ((cmd.length() >7) &&
                   (cmd.substring(0,7).equals("nobody"))){
            if(viewSource == false){
              viewSource = true;
              menuNewSign();
              if(tree.getLastSelectedPathComponent() != null){
                DefaultMutableTreeNode node =
                    (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
                Object nodeInfo = node.getUserObject();
                if(nodeInfo instanceof MailIndex){
                  MailIndex index = (MailIndex)nodeInfo;
                  mailsRemark(index.mailId);
            else{
              viewSource = false;
              menuNeuZeichnen();
              if(tree.getLastSelectedPathComponent() != null){
                DefaultMutableTreeNode node =
                    (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
                Object nodeInfo = node.getUserObject();
                if(nodeInfo instanceof MailIndex){
                  MailIndex index = (MailIndex)nodeInfo;
                  mailsRemark(index.mailId);
          else if (cmd.equals("Setup")){
            SetupOpen();
        else if (obj instanceof JButton){
          String cmd = event.getActionCommand();
          if (cmd.equals("aga")){
            mailsHolen();
          else if (cmd.equals("Creator Open")){
            creatorOpem();
          else if(cmd.equals("rep")){
            reply();
          else if(cmd.equals("fwd")){
            forward();
          else if(cmd.equals("Setup Open")){
            SetupOpen();
          else if(cmd.equals("adr")){
            addressbookOpen();
          else if(cmd.equals("delete")){
            delete();
          else if(cmd.equals("Information")){
            myInfo.setVisible(true);
            myInfo.b.requestFocus();
      private class myWindowListener extends WindowAdapter{
        public void windowClosing(WindowEvent event){
          end();
      private class myTreeSelectionListener implements TreeSelectionListener{
        public void valueChanged(TreeSelectionEvent e) {
          DefaultMutableTreeNode node =
              (DefaultMutableTreeNode)(e.getPath().getLastPathComponent());
          Object nodeInfo = node.getUserObject();
          if(nodeInfo instanceof MailIndex){
            MailIndex index = (MailIndex)nodeInfo;
            mailsAnzeigen(index.mailId);
            index.read = "Yes";
    }

  • Trouble compiling a stored procedure

    Hello, I have trouble compiling a stored procedure. I include part of the code because I think the key problem is illustrated in these lines:
    date1 is declared as a DATE.
    index_value2 NUMBER;
    BEGIN
    date1 := (select sysdate from dual);
    index_value2 := (select index_value from tmsdat.a_index_values where price_date < (SELECT sysdate -180
       FROM dual) and price_date > (SELECT sysdate -210
       FROM dual));
    [\code]
    The problem seems to be that a more complex syntax is included in the allocation statement (:=), can that be the case? That is, no select etc??
    How is this solved?
    Any help much appreciated!
    best regards
    Harald                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Well, actually WhiteHat´s magic did the trick, but two errors:
    temp := (select (to_number(to_char(sysdate, 'DD'))-1)/(decode(to_char(sysdate,'MM'),'02',28,30)) as result
       from dual);
    [\code]
    this line generates problems but I think the approach is the same maybe, that is:
    select to_number(to_char(sysdate, 'DD'))-1)/(decode(to_char(sysdate,'MM'),'02',28,30)) into temp as result frmo dual
    Further, some error about encountering end of line?
    END CONVERT_MARKET_INDEX;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Running DS-5 armcc compiled code (PIC) under Windows EC 2013

    Hi All,
    i just wanted to know if it is generally (officially) supported to run code that is compiled via the armcc (5.03) from DS-5 under Windows Embedded Compact 2013. Or if this is discouraged (reasons?).
    The problem i have:
    The bootloader contains some code that must be run during Windows EC Startup. So this code is loaded from the Flash, copied to RAM (reserved and commited via VirtualAlloc and marked as executable) and then the functions are called via FunctionPointers.
    The code is compiled and linked as position independent and the stack base register is set accordingly before any function is called via pointer and reset when it returns.
    This works in about 9 out of 10 tests without problems. But sometimes i get all sort of exceptions (Data Abort, Prefetch Abort, Unknown Instruction, ...). Most (if not all) of the time they occur when the position independent code runs on one of the two
    cores.
    The code runs on an i.MX6DQ (dual).
    If i only enable one core, i can't reproduce the problem (i assume that multicore-handling and multithreading in WinEC 2013 Update 10 is really well tested and works without problems, so this can't be the real reason).
    I've thoroughly checked and debugged the code, i'm really sure there is no illegal access or other problem with the code itself.
    Could it be a problem to call code compiled via DS-5 armcc? I've compared assembler code that Visual Studio/Platform Builder generates with code that DS-5 generates (but i'm no assembler expert). I can't see any obvious special code that is added by Visual
    Studio/Platform Builder (i.e. that functions need) that is not there in the DS-5 code.
    Best Regards
    Sebastian

    So I think you could be able to image some code for ROM from another compiler and without knowledge of Windows CE. However, if the code will be called from Windows CE, this becomes more difficult requiring very careful isolation from the
    MMU state, processor state, kernel/user mode, etc. Code that works great when called from the bootloader might not work at all from Windows CE itself. The main problem with mixing code from different compilers is the object file format and conventions for
    entry and public names. Very unlikely that you'd be able to "link" code from any other compiler with PB-compiled code.
    You might think about the x86 image which can easily call BIOS from the bootloader but which can't even begin to call BIOS from CE itself. The problem isn't the compiler (which is different), but the operating environment differences and assumptions.
    Paul T.

  • Troublesho​oting compiled code?

    I am using Fieldpont modules to control some lab tests.  Since we have a few separate tests, we've decided to use compiled code to cut down on Labview costs. 
    The issue I'm having is when I have an error in the compiled code on a new install.  Is there any way to see where in the code the error is occurring?  Maybe some sort of test run mode or something? I know the code interacts with the windows registry as well as a few files on the hard drive. I think this is where the problem is. Unfortunately, I did not write the code, so I'm not certain where the problem could be.  I have always been able to easily troubleshoot issues with code when running the full Labview software, but with the compiled code, you can't see the block diagram.
    Any help would be greatly appreciated.
    Tony

    Hi Scubadude,
    I have included a link to a help file that walks through how to debug applications on remote systems.
    Debugging Applications and Shared Libraries:
    http://zone.ni.com/reference/en-XX/help/371361J-01​/lvhowto/debug_apps_dlls/
    Wear
    National Instruments
    Product Support Engineer

  • How to retrieve constants value from compiled code in jar file?

    Hi everyone,
    I've been looking for a way to solve this for a week now, without any much success... and I've finally decided to ask the Java gurus for a solution! :-)
    Here's what I am basically trying to do:
    I have several jar files in which there are only compiled code (.class).
    In every class, there are 2 constants (declared as static final String) that I would like to retrieve (one is the version and the other the date of the last modification).
    My goal is to print a list of all the classes in the jar files with the values of these 2 constants for each class.
    The solution that I have right now to do this does not work properly: for now, I read all the elements of the classpath, check if these are jar files, and if so, I look into each one and load all the classes one by one and print the results.
    The problem with this is that it uses the method Class.forName(className) and as some classes are unfortunately present in many jar files (2 or 3 copies), once the classes have been loaded, then it won't be "reloaded".
    Without the possibility to "reload" these classes, I cannot see inconsistencies in the versions of the classes present in the jar files.
    I have read many articles, and I thought that I could then use a custom classloader and create a new instance of this classloader for each jar file.
    2 problems with this:
    - according to many posts in the different forums I have read, the jar files should not appear in the CLASSPATH (but this would be easier for me if I could use it...)
    - some classes will not be loaded if some classes (present in other jar files) are not loaded... and this makes things really really complicated to implement...
    So, I thought that I was maybe doing this the wrong way, and that there might be an easy way out of this...
    In fact, I do not need to load the classes... all I need to do, is take a sneak peek at the constants and print their values... and that's it!
    Somehow, I think that this is possible to retrieve the values of compile time constants (declared as static final String) as I can see that with Eclipse (when opening a jar file).
    So, my question is: how can I do that within my java application?
    Or maybe there is another easier solution to do what I need?
    Thanks in advance for your help!

    Hi everyone,
    I've been looking for a way to solve this for a week now, without any much success... and I've finally decided to ask the Java gurus for a solution! :-)
    Here's what I am basically trying to do:
    I have several jar files in which there are only compiled code (.class).
    In every class, there are 2 constants (declared as static final String) that I would like to retrieve (one is the version and the other the date of the last modification).
    My goal is to print a list of all the classes in the jar files with the values of these 2 constants for each class.
    The solution that I have right now to do this does not work properly: for now, I read all the elements of the classpath, check if these are jar files, and if so, I look into each one and load all the classes one by one and print the results.
    The problem with this is that it uses the method Class.forName(className) and as some classes are unfortunately present in many jar files (2 or 3 copies), once the classes have been loaded, then it won't be "reloaded".
    Without the possibility to "reload" these classes, I cannot see inconsistencies in the versions of the classes present in the jar files.
    I have read many articles, and I thought that I could then use a custom classloader and create a new instance of this classloader for each jar file.
    2 problems with this:
    - according to many posts in the different forums I have read, the jar files should not appear in the CLASSPATH (but this would be easier for me if I could use it...)
    - some classes will not be loaded if some classes (present in other jar files) are not loaded... and this makes things really really complicated to implement...
    So, I thought that I was maybe doing this the wrong way, and that there might be an easy way out of this...
    In fact, I do not need to load the classes... all I need to do, is take a sneak peek at the constants and print their values... and that's it!
    Somehow, I think that this is possible to retrieve the values of compile time constants (declared as static final String) as I can see that with Eclipse (when opening a jar file).
    So, my question is: how can I do that within my java application?
    Or maybe there is another easier solution to do what I need?
    Thanks in advance for your help!

  • Error during distribution for compiled code generation-Reply

    Hi,
    Looking at your error messages, it looks as though your build is failing during the code generation phase of an autocompilation. To determine why the code generator crashed, either look in the $FORTE_ROOT/log/forte_ex*.log files or don't use autocompilation and use fcompile.
    There are many reasons why the code generator could crash. Some of the things I've come across are running out of memory and trying to find invalid classes.
    If its the invalid class problem you'll find a message like:
    Generating code for partition BLTCustomWindow_cl0_Part1.
    ERROR: Exiting due to following exception:
    SYSTEM ERROR: Client partition FTCompile_cl0_Client was terminated by escaped
    exception. See the remainder of the error stack for more information.
    Class: qqsp_ResourceException
    Error #: [1001, 3]
    Detected at: qqrt_ForteExecAgent::LoadPartition at 1
    Error Time: Tue Aug 18 17:52:44
    Exception occurred (locally) on partition "Forte_Executor", (partitionId =
    9EA25A00-36FE-11D2-87C4-502F15BEAA77:0x1, taskId =
    [9EA25A00-36FE-11D2-87C4-502F15BEAA77:0x1.6]) in application
    "FTCompile_cl0", pid 28331 on node stardev in environment <unknown>.
    FATAL ERROR: Invalid class ProductBMServices.ProductSecurityMgrProxy
    (0x4ecd,0x19a)
    Class: qqsp_ImplementationException
    Detected at: qqcg_TRclass::SetClass at 2
    Last TOOL statement: method ForteCompiler.ProcessPGF
    Error Time: Tue Aug 18 17:52:44
    Exception occurred (locally) on partition "Forte_Executor",
    (partitionId = 9EA25A00-36FE-11D2-87C4-502F15BEAA77:0x1, taskId =
    [9EA25A00-36FE-11D2-87C4-502F15BEAA77:0x1.6]) in application
    "FTCompile_cl0", pid 28331 on node stardev in environment <unknown>.
    The solution for this instance is to clean up the invalid classes using the c4tstdrv utility.
    c4tstdrv > setrepos star8
    c4tstdrv > setwork dmcompiledbuild
    c4tstdrv > open
    Type Service Flags Level
    err sh * 255
    trc rp 1 4
    c4tstdrv > findproj productbmservices
    c4tstdrv > cleanuprtclasses
    Removing extraneous RTclass ProductShootingLocationMgrProxy
    Removing extraneous RTclass PRTerritoryBaseMgrProxy
    Removing extraneous RTclass PRTerritoryMgrProxy
    Removing extraneous RTclass TalentBaseMgrProxy
    Removing extraneous RTclass TalentTypeMgrProxy
    Removing extraneous RTclass TitleTypeBaseMgrProxy
    Removing extraneous RTclass TitleTypeMgrProxy
    Removing extraneous RTclass ProductSecurityBaseClass
    Removing extraneous RTclass ProductSecurityBaseQuery
    Removing extraneous RTclass ProductSecurityQuery
    Removing extraneous RTclass ProductSecurityMgrProxy
    c4tstdrv > commit
    c4tstdrv > exit
    Integrate the changes to the workspace, start the build again and this should have cured the problem.
    However, its hard to know what the cause of your problem is without seeing the output in the log files.
    Good luck.
    Mark Carruthers
    20th Century Fox
    "Forte Consultants" <[email protected]> 01/22/99 08:35am >>>
    Hi,
    I'm doing application distribution for my application using a fscript
    script and am forcing compilation on 2 of my partitions.
    This I have been doing from quite sometime successfully. Recently I
    developed a new service and plugged it into my application for
    deployment.
    I'm successfully able to distribute & deploy the interpreted code. But
    I'm getting a long list of system errors when I try doing distribution
    for compiled code. And I see only one of the .exe generated instead of
    two because of which I'm unable to go ahead with installaion. I would
    appreciate if anybody let me know why this's happening ?. The following
    is the main chunk of this error list.
    Thanks in advance.
    --Anand Ramaswamy
    SYSTEM ERROR: Cannot resolve the distributed reference for an object of
    class
    (qqlo_Object) named (<Unknown>) for the reasons below.
    Class: qqsp_DistAccessException
    Error #: [601, 144]
    Detected at: qqdo_ProxyMgr::ResolveOutGoingProxy at 10
    Error Time: Fri Jan 22 10:44:22
    Exception occurred (locally) on partition "Fscript_cl9_Client",
    (partitionId = 32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1,
    taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1.1]) in application
    "fscript", pid 4b81 on node MOOSUP in environment IGTSDENV.
    SYSTEM ERROR: Can not initially communicate with the object named
    (Unnamed),
    which is supposed to be in partition
    (32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x616:0x1).
    Class: qqsp_DistAccessException
    Error #: [601, 140]
    Detected at: qqdo_ProxyMgr::CheckAccess at 1
    Error Time: Fri Jan 22 10:44:22
    Exception occurred (locally) on partition "Fscript_cl9_Client",
    (partitionId = 32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1,
    taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1.1]) in application
    "fscript", pid 4b81 on node MOOSUP in environment IGTSDENV.
    SYSTEM ERROR: Attempt to send to unknown destination partition
    (32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x616:0x1).
    Class: qqsp_DistAccessException
    Error #: [601, 102]
    Detected at: qqdo_PartitionMgr::SendMsg at 1
    Error Time: Fri Jan 22 10:44:22
    Distributed method called: qqdo_InternalMessage.<Message> (object
    name
    Unnamed) from partition "CodeGenerationSvc_cl0_Part1-router",
    (partitionId
    = 32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615:0x1, taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615.2]) in application
    "CodeGenerationSvc_cl0", pid 7487 on node MOOSUP in environment
    IGTSDENV
    Exception occurred (locally) on partition "Fscript_cl9_Client",
    (partitionId = 32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1,
    taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1.1]) in application
    "fscript", pid 4b81 on node MOOSUP in environment IGTSDENV.
    SYSTEM ERROR: Partition (32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x616:0x1)
    no
    longer exists. The process associated with the partition probably
    terminated.
    Class: qqsp_DistAccessException
    Detected at: qqdo_PartitionMgr::CheckStarted at 1
    Error Time: Fri Jan 22 10:44:22
    Exception occurred (locally) on partition "Fscript_cl9_Client",
    (partitionId = 32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1,
    taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1.1]) in application
    "fscript", pid 4b81 on node MOOSUP in environment IGTSDENV.
    SYSTEM ERROR: This method invocation is being retried because the
    failures
    shown below and the fact that the dialog duration is MESSAGE. This is
    try #2.
    Class: qqsp_DistAccessException
    Error #: [601, 54]
    Detected at: qqdo_Message::Failed at 1
    Error Time: Fri Jan 22 10:44:19
    Exception occurred (locally) on partition "Fscript_cl9_Client",
    (partitionId = 32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1,
    taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1.1]) in application
    "fscript", pid 4b81 on node MOOSUP in environment IGTSDENV.
    SYSTEM ERROR: The load balanced router is disabled or has no members.
    This
    can happen if all of the members terminated or failed.
    Class: qqsp_DistAccessException
    Error #: [601, 161]
    Detected at: qqdo_LbRouter::Route at 1
    Error Time: Fri Jan 22 10:44:19
    Distributed method called: GenerationMgrProxy.GeneratePartitionCode
    (object name
    site/codegenerationsvc_cl0/codegenerationsvc_cl0-codegensvc)
    from partition "Fscript_cl9_Client", (partitionId =
    32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1, taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614.2]) in application
    "fscript",
    pid 4b81 on node MOOSUP in environment IGTSDENV
    Exception occurred (remotely) on partition
    "CodeGenerationSvc_cl0_Part1-router", (partitionId =
    32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615:0x1, taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1.10]) in
    application
    "CodeGenerationSvc_cl0", pid 7487 on node MOOSUP in environment
    IGTSDENV.
    SYSTEM ERROR: This method invocation is being retried because the
    failures
    shown below and the fact that the dialog duration is MESSAGE. This is
    try #1.
    Class: qqsp_DistAccessException
    Error #: [601, 54]
    Detected at: qqdo_Message::Failed at 1
    Error Time: Fri Jan 22 10:44:15
    Exception occurred (locally) on partition "Fscript_cl9_Client",
    (partitionId = 32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1,
    taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1.1]) in application
    "fscript", pid 4b81 on node MOOSUP in environment IGTSDENV.
    SYSTEM ERROR: Access to a load balanced router member (which is a
    service
    object) failed for the reasons below.
    Class: qqsp_DistAccessException
    Error #: [601, 162]
    Detected at: qqdo_LbRouter::Route at 2
    Error Time: Fri Jan 22 10:44:15
    Distributed method called: GenerationMgrProxy.GeneratePartitionCode
    (object name
    site/codegenerationsvc_cl0/codegenerationsvc_cl0-codegensvc)
    from partition "Fscript_cl9_Client", (partitionId =
    32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1, taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614.3]) in application
    "fscript",
    pid 4b81 on node MOOSUP in environment IGTSDENV
    Distributed method called: qqlo_Object.<Message> (object name
    Unnamed)
    from partition "Forte_Executor", (partitionId =
    32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615, taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615.12]) in application
    "CodeGenerationSvc_cl0", pid 7487 on node MOOSUP in environment
    IGTSDENV
    Exception occurred (remotely) on partition
    "CodeGenerationSvc_cl0_Part1-router", (partitionId =
    32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615:0x1, taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1.10]) in
    application
    "CodeGenerationSvc_cl0", pid 7487 on node MOOSUP in environment
    IGTSDENV.
    SYSTEM ERROR: Cannot resolve the distributed reference for an object of
    class
    (qqlo_Object) named (<Unknown>) for the reasons below.
    Class: qqsp_DistAccessException
    Error #: [601, 144]
    Detected at: qqdo_ProxyMgr::ResolveOutGoingProxy at 10
    Error Time: Fri Jan 22 10:44:15
    Distributed method called: qqlo_Object.<Message> (object name
    Unnamed)
    from partition "Forte_Executor", (partitionId =
    32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615, taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615.12]) in application
    "CodeGenerationSvc_cl0", pid 7487 on node MOOSUP in environment
    IGTSDENV
    Exception occurred (remotely) on partition
    "CodeGenerationSvc_cl0_Part1-router", (partitionId =
    32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615:0x1, taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1.10]) in
    application
    "CodeGenerationSvc_cl0", pid 7487 on node MOOSUP in environment
    IGTSDENV.
    SYSTEM ERROR: This distributed reference was previously invalidated due
    to the
    reasons below.
    Class: qqsp_DistAccessException
    Error #: [601, 132]
    Detected at: qqdo_ProxyMgr::ResolveOutGoingProxy at 3
    Error Time: Fri Jan 22 10:44:15
    Exception occurred (remotely) on partition
    "CodeGenerationSvc_cl0_Part1-router", (partitionId =
    32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615:0x1, taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1.10]) in
    application
    "CodeGenerationSvc_cl0", pid 7487 on node MOOSUP in environment
    IGTSDENV.
    INFORMATION: The connection to the partner was terminated by the
    Communication
    Manager for the reasons below.
    Class: qqsp_DistAccessException
    Detected at: qqdo_PartitionMgr::StopLocation at 1
    Error Time: Fri Jan 22 10:44:15
    Exception occurred (remotely) on partition
    "CodeGenerationSvc_cl0_Part1-router", (partitionId =
    32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615:0x1, taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1.10]) in
    application
    "CodeGenerationSvc_cl0", pid 7487 on node MOOSUP in environment
    IGTSDENV.
    INFORMATION: Network partner closed connection. This usually means the
    process at the other end of the wire failed. Please go look there and
    find
    out why.
    Class: qqsp_DistAccessException
    Detected at: qqcm_HoseFSM::ReceivedClose at 2
    Error Time: Fri Jan 22 10:44:15
    Exception occurred (remotely) on partition
    "CodeGenerationSvc_cl0_Part1-router", (partitionId =
    32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615:0x1, taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1.10]) in
    application
    "CodeGenerationSvc_cl0", pid 7487 on node MOOSUP in environment
    IGTSDENV.
    INFORMATION: Asynchronous Failure: Recieved a close from the network
    partner:
    Internet Location - Host: moosup.iroquois.com Port Number: 2504 Dot:
    193.1.11.26 %LINKDISCON, network partner disconnected logical link
    Event 4
    Class: qqsp_DistAccessException
    Detected at: qqcm_HoseFSM::ReceivedClose at 1
    Error Time: Fri Jan 22 10:44:15
    Exception occurred (remotely) on partition
    "CodeGenerationSvc_cl0_Part1-router", (partitionId =
    32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615:0x1, taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1.10]) in
    application
    "CodeGenerationSvc_cl0", pid 7487 on node MOOSUP in environment
    IGTSDENV.
    SYSTEM ERROR: This method invocation is being retried because the
    failures
    shown below and the fact that the dialog duration is MESSAGE. This is
    try #1.
    Class: qqsp_DistAccessException
    Error #: [601, 54]
    Detected at: qqdo_Message::Failed at 1
    Error Time: Fri Jan 22 10:44:15
    Exception occurred (remotely) on partition
    "CodeGenerationSvc_cl0_Part1-router", (partitionId =
    32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615:0x1, taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1.10]) in
    application
    "CodeGenerationSvc_cl0", pid 7487 on node MOOSUP in environment
    IGTSDENV.
    INFORMATION: The connection to the partner was terminated by the
    Communication
    Manager for the reasons below.
    Class: qqsp_DistAccessException
    Detected at: qqdo_PartitionMgr::StopLocation at 1
    Error Time: Fri Jan 22 10:44:15
    Distributed method called: qqlo_Object.<Message> (object name
    Unnamed)
    from partition "Forte_Executor", (partitionId =
    32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615, taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615.12]) in application
    "CodeGenerationSvc_cl0", pid 7487 on node MOOSUP in environment
    IGTSDENV
    Exception occurred (remotely) on partition
    "CodeGenerationSvc_cl0_Part1-router", (partitionId =
    32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615:0x1, taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1.10]) in
    application
    "CodeGenerationSvc_cl0", pid 7487 on node MOOSUP in environment
    IGTSDENV.
    INFORMATION: Network partner closed connection. This usually means the
    process at the other end of the wire failed. Please go look there and
    find
    out why.
    Class: qqsp_DistAccessException
    Detected at: qqcm_HoseFSM::ReceivedClose at 2
    Error Time: Fri Jan 22 10:44:15
    Exception occurred (remotely) on partition
    "CodeGenerationSvc_cl0_Part1-router", (partitionId =
    32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615:0x1, taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1.10]) in
    application
    "CodeGenerationSvc_cl0", pid 7487 on node MOOSUP in environment
    IGTSDENV.
    INFORMATION: Asynchronous Failure: Recieved a close from the network
    partner:
    Internet Location - Host: moosup.iroquois.com Port Number: 2504 Dot:
    193.1.11.26 %LINKDISCON, network partner disconnected logical link
    Event 4
    Class: qqsp_DistAccessException
    Detected at: qqcm_HoseFSM::ReceivedClose at 1
    Error Time: Fri Jan 22 10:44:15
    Exception occurred (remotely) on partition
    "CodeGenerationSvc_cl0_Part1-router", (partitionId =
    32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x615:0x1, taskId =
    [32271CD0-4E62-11D2-AF29-9F40A9E1AA77:0x614:0x1.10]) in
    application
    "CodeGenerationSvc_cl0", pid 7487 on node MOOSUP in environment
    IGTSDENV.
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Hi,
    If this INCLUDE is in a function group go the MAIN program and activate from there.
    Can you list out the include name?

  • Compiled Code Error Running Excel

    Writing to Excel works fine with source code but gives this error with compiled code:
    Open VI Reference in Dispose Report.vi->Write_to_Excel.vi->Golden_Thread_V2.vi<APPEND>
    VI Path: <b>C:\Golden Thread\Golden Thread V2.2.exe\Excel_Quit.vi</b>
    Built Application or Shared Library (DLL): Make sure all dynamically loaded VIs were properly included in the build specification for the application or shared library.
    Any thoughts???
    Thanks.

    Hi Steve,
    if you use for example the "Append Table to Report.vi", then you have in the "Excel" case a dynamic loaded vi, also in the "New Report.vi". See the picture.
    See this KB: http://digital.ni.com/public.nsf/allkb/C38CE3F30542D65B86256F0E00740DD8
    Mike
    Message Edited by MikeS81 on 06-18-2008 03:42 PM
    Attachments:
    Unbenannt1.PNG ‏20 KB

  • Trouble compiling for printed documentation

    hello, i am having trouble compiling a new document layout i
    have created, i have followed peter grainges instructions on his
    website but it always fails to generate straight away. Im using
    Robohelp x5 with word 2000, does anyone have any ideas?
    thanks steve

    Steve
    Was RH installed on the PC you are using with you logon or
    that of the person whose job you have taken over? It sounds very
    much like the latter and this is exactly what I would expect to
    happen.
    Try creating a new project with just a couple of topics and
    printing from that. It will likely also fail. If it does that
    pretty much confirms my theory. Uninstall and reinstall RH with
    your logon and with admin rights attached and the problem will
    likely go away.

  • Trouble compiling servlet example

    Hi All, I am trying out an example for servlets and I ran into trouble compiling the the file called "FormProcessingServlet.java" in tutorial located here: http://developer.java.sun.com/developer/onlineTraining/Servlets/Fundamentals/magercises/FormPostingAndProcessing/index.html
    The exact problem happens in this line:
    isStructure = context.getResourceAsStream(paramStructureFile[0]);
    The error says:
    FormProcessingServlet.java:127: cannot resolve symbol
    symbol : method getResourceAsStream (java.lang.String)
    location: interface javax.servlet.ServletContext
    isStructure = context.getResourceAsStream(paramStructureFile[0]);
    anyone else ran into this problem? How do I fix this? Thanks.

    "cannot resolve symbol" means that the JVM can't find a particular class.
    Adjust your systems classpath variable to include all the jar files that you use, I also add "." to include files in the current directory I'm working from.

  • Having trouble compiling

    I am a total newbie at programming and I am having trouble compiling. In the MS-DOS prompt, I located the folder where my .java file is located and typed the following:
    javac SampleProgram.java
    I received a "Bad command or file name" error. I am typing the names correctly. I am using Java 2 SDK, Standard Edition Version 1.3.1. Am I doing something wrong?
    Thanks for any help.

    That should fix it. The problem is that DOS needs to know where to find the executable files like javac.exe
    You can either set the path temporarily by typing
    SET PATH=.;c:\jdk1.3.1\bin
    at the command prompt each time you open a command window, or you can set it more permanently by adding it to your startup config. This will depend on your OS. On win 98 for example, there is an AUTOEXEC.BAT (usually with a SET PATH command already present). You could open this in notepad to add/change:
    SET PATH=C:\WINDOWS
    to
    SET PATH=C:\WINDOWS;.;C:\JDK1.3.1\BIN
    Reboot to make the changes take effect. Other OS's may have a special dialog to set this kind of command.
    Hope this helps some.

  • Compile code in a file

    i have some java codes in my "fl.txt"(c:\fl.txt). these are;
    public class file_{
    public static void main(String args[]){
    System.out.print("hello world");
    }i want to compile these code from my program(i am building it with java) at runtime.. how can ii do that.i think i need to use runtime.exec() method but i dont know how can i compile these codes in a file....

    It is possible to dynamically compile code from within a running Java program,
    but you should have a damn good reason for doing so.
    Check out the documentation for javac: http://java.sun.com/javase/6/docs/technotes/tools/windows/javac.html
    <quote>
    javac supports the new Java Compiler API defined by the classes and interfaces in the javax.tools package.
    Example
    To perform a compilation using arguments as you would give on the command line, you can use the following:
    JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
    int rc = javac.run(null, null, null, args);This will write any diagnostics to the standard output stream, and return the exit code that javac would give when invoked from the command line.
    You can use other methods on the javax.tools.JavaCompiler interface to handle diagnostics, control where files are read from and written to, and so on.
    </quote>
    If you are using an older version of Java, check out the documentation to see the old interface to do this (com.sun.tools.javac.Main).

  • Error when run the compiled code

    I have code below,
    import java.sql.*;
    public class testmysql{
         public static void main(String args[]){
              Connection conn = null;
    try{
    String userName = "root";
    String password = "password";
    String url = "jdbc:mysql://localhost:3307/ectol_db";
    Class.forName ("com.mysql.jdbc.Driver").newInstance ();
    conn = DriverManager.getConnection (url, userName, password);
    System.out.println ("Database connection established");
    }catch (Exception e) {
              e.printStackTrace();
    System.err.println ("Cannot connect to database server");
    }finally{
    if (conn != null){
    try{
    conn.close ();
    System.out.println ("Database connection terminated");
    }catch (Exception e) {
         e.printStackTrace();
         /* ignore close errors */
    and i have the mysql-connector-5.0.6.jar
    I able to compile code with javac testmysql.java command
    However, when i try to run the code with java testmysql command, it prompt me error below
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    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:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at testmysql.main(testmysql.java:11)
    Cannot connect to database server
    Anyone can help?

    ccwoon80 wrote:
    Actually, the jar and class file was in the same path...
    Thus, what the correct command i need to run the my code?Then your classpath would be .;mysql.jar (or whatever the heck the name of the connector was).
    So java -cp .;mysql.jar foo.bar.MyClass

  • Compiler Code Generation API

    I would like to ask if you guys could make a Compiler Code Generation API.  This would allow developers who would like to fine-tune details you guys probably don't have time to do, for projects we think its important on.  Specifically with [Bindable] and {} code generation.
    I would like to be able, and many others I'm sure, to turn Binding on/off (conditional binding), and add more complicated expressions, but that's currently impossible, unless I rewrote the core UIComponent and everything.  Or unless I had access to the generated code through a nice API which shouldn't take you guys long at all: you already are generating lots of code and have templates for it, I would just like to ask for easy access to those templates.
    Please let me know what you think.  Thanks a lot for your time.
    Lance

    It's something we've thought about but it's not a high enough priority right now.  Certainly a feature that folks could think about implementing on their own and contributing back though.  It tends to be more complicated than you'd think though
    Matt

  • Java.lang.NoClassDefFoundError: com/sun/j3d/utils/applet/MainFrame         at HelloUniverse.main(Compiled Code)

    I'm getting this error
    java.lang.NoClassDefFoundError: com/sun/j3d/utils/applet/MainFrame
    at HelloUniverse.main(Compiled Code)
    I receive this error when I try to run the demos that are in the /usr/java1.1/demo folder.
    I followed the directions to install java3d. I installed the java3d binary in the top part of
    the JDK directory then ran the binary. Everything installed o.k., but I cannot run
    any of the demos. I also have J2SE 1.2.2_05a, JDK 1.1.8_10, and.
    JRE 1.1.8_10 installed. My operating system is SunOS 5.6, Solaris 2.6. My workstation
    is an Ultra 5 with 374mb ram.
    Here is part of the install intructions.
    Place the java3d1_2-solsparc.bin file into the top level directory
    of the JDK you wish to install Java 3D into. Execute the
    java3d1_2-solsparc.bin file (ex: sh java3d1_2-solsparc.bin).
    After installation, you may remove this file.
    The Java 3D(TM) SDK includes several demo programs that can
    verify correct installation. Assuming your Java 2 SDK is installed
    at ~/Solaris_JDK_1.2.2_05, try the following:
    cd ~/Solaris_JDK_1.2.2_05/demo/java3d/HelloUniverse
    java HelloUniverse
    Note: Many more demos are available under the demo/java3d/
    directory. Some of the demos require a maximum memory
    pool larger than the default in java. To increase the
    maximum memory pool to 64 meg, add the following command
    line options to java or appletviewer:
    java: -mx64m
    appletviewer: -J-mx64m
    You do not need to include the J3D jar files in your CLASSPATH,
    nor do you need to include the J3D shared libraries in your PATH.
    You should include "." in your CLASSPATH or ensure that CLASSPATH
    is not set.
    I'm not sure how to set set/unset the CLASSPATH and I'm not sure if I was supposed to
    place the binary file in the /usr/java1.1 or /usr/java or /usr/java1.2 directory.
    Can anyone help?
    tomjones

    -- If jar size isn't an issue, I recommend using thick "weblogic.jar" instead of the thin "wl*.jar" jars. The thick jar is a better performer, is used by more customers, and has more features. Otherwise:
              -- It might help to use the thin client jars from a later service pack - several service packs have been released since SP2, or you might even try using jars from a recent 9.2 SP or even 10.0.
              -- Also, check to see if the 1.4.2 JVM is up-to-date and/or try switching from the Sun JVM to the JRockit JVM (or vice-versa).
              -- Finally, it might help to check if your XP environment matches your Linux environment (JVM command-line, classpath, etc).
              -- Also: The IIOP newsgroup may also have some advice. The thin client uses the IIOP protocol even when a "t3:" URL is specified by the application.
              Tom

Maybe you are looking for