Help with Declaring a Class with a Method and Instantiating an Object

hello all i am having trouble understanding and completing a lab tutorial again!
im supposed to compile an run this code then save work to understand how to declare aclass with a method an instantiate an object of the class with the following code
// Program 1: GradeBook.java
// Class declaration with one method.
public class GradeBook
// display a welcome message to the GradeBook user
public void displayMessage()
System.out.println( "Welcome to the Grade Book!" );
} // end method displayMessage
} // end class GradeBook
// Program 2: GradeBookTest4.java
// Create a GradeBook object and call its displayMessage method.
public class GradeBookTest
// main method begins program execution
public static void main( String args[] )
// create a GradeBook object and assign it to myGradeBook
GradeBook myGradeBook = new GradeBook();
// call myGradeBook's displayMessage method
myGradeBook.displayMessage();
} // end main
} // end class GradeBookTest4
i saved above code as shown to working directory filename GradeBookTest4.java
C:\Program Files\Java\jdk1.6.0_11\bin but recieved error message
C:\Program Files\Java\jdk1.6.0_11\bin>javac GradeBook4a.java GradeBookTest4.java
GradeBookTest4.java:2: class, interface, or enum expected
^
GradeBookTest4.java:27: reached end of file while parsing
^
2 errors
can someone tell me where the errors are because for class or interface expected message i found a solution which says 'class? or 'interface' expected is because there is a missing { somewhere much earlier in the code. i dont know what "java:51: reached end of file while parsing " means or what to do to fix ,any ideas a re appreciated                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Doesn't solve your problem, but this works for me...
public class GradeBook
  public void displayMessage() {
    System.out.println( "Welcome to the Grade Book!" );
  public static void main( String args[] ) {
    try {
      GradeBook gradeBook = new GradeBook();
      gradeBook.displayMessage();
    } catch (Exception e) {
      e.printStackTrace();
}

Similar Messages

  • Need help with using selected class with includes...

    Hi guys,
    I'm using PHP includes for my site and in the header include I have my main navigation - so it's drawn in to whatever page the user goes to from header.php.
    I want to have a 'selected' <li> class for the navigation so the relevant button is highlighted depending on which page/section the user is on...
    How would I go about implementing it into header.php - is there a way I can put a bit of PHP in each of the pages to make the appropiate <li> in header.php use the 'selected' class?
    Thank you and I hope to hear from you.
    SM

    I'm sure there will be an easier way than this for PHP but if you give each menu item a class, you can then give each <body> a different id (or class) to determine where the user is.
    Eg:
    CSS
    nav li.menu_home a{style here} /* class is 'menu_home' for home menu item */
    #home nav li.menu_home a{style here} /* the id of 'home' is added to the body tag on the home page, <body id="home"> */
    HTML
    <body id="home">
    <!-- navigation include -->
    <nav>
    <ul>
    <li class="menu_home"><a href="">Home</a></li>
    </ul>
    </nav>
    <!-- end navigation include -->
    </body>
    Or you could try searching for a javascript method.

  • Class errors: undefined methods and properties

    i have a document with objects in the library with the class Hitte, Kern, Ring and Ring_01 [to Ring_16]
    tge Ring_ pieces have a subclass of RingSegment.
    the code of RingSegment.as is as following:
    package {
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.display.MovieClip;
        import flash.display.DisplayObjectContainer;
        import flash.display.Stage;
        public class RingSegment extends MovieClip {
            public var verwijderd=0;
            public function addHitte():void {
                var Hitte_mc:Hitte=new Hitte();
                Hitte_mc.x=Math.random()*550;
                Hitte_mc.y=Math.random()*400;
                stage.addChild(Hitte_mc);
            Hitte_mc.addEventListener(MouseEvent.MOUSE_DOWN,slepenStart);
            Hitte_mc.addEventListener(MouseEvent.MOUSE_UP,slepenStop);
            public function slepenStart(evt:MouseEvent):void {Hitte_mc.startDrag();}
            public function slepenStop(evt:MouseEvent):void {Hitte_mc.stopDrag();}
            public function verdwijnen (evt:Event) {
                if (evt.target.hitTestObject(Hitte_mc)) {
                    evt.target.alpha+=-0.1;
                    if (evt.target.alpha <= 0.1 && evt.target.alpha > 0) {
                        evt.target.alpha = 0;
                        verwijderd+=1;
    which should add a Hitte_mc to the stage, make it draggable , and make the Ring_ objects react to a hittest with the Hitte_mc
    but I get tons of errors:
    how can i fix these errors?

    Oh, I see. I did not notice this before. The class should be:
    package {
         import flash.events.Event;
         import flash.events.MouseEvent;
         import flash.display.MovieClip;
         import flash.display.DisplayObjectContainer;
         import flash.display.Stage;
        public class RingSegment extends MovieClip {
              public var verwijderd = 0;
              private var Hitte_mc:Hitte;
              public function addHitte():void {
                   if (stage) init();
                   else addEventListener(Event.ADDED_TO_STAGE, init);
              private function init(e:Event = null):void
                   removeEventListener(Event.ADDED_TO_STAGE, init);
                   Hitte_mc = new Hitte();
                   Hitte_mc.x = Math.random() * 550;
                   Hitte_mc.y = Math.random() * 400;
                   stage.addChild(Hitte_mc);
                   Hitte_mc.addEventListener(MouseEvent.MOUSE_DOWN,slepenStart);
                   Hitte_mc.addEventListener(MouseEvent.MOUSE_UP,slepenStop);
              public function slepenStart(e:MouseEvent):void { Hitte_mc.startDrag(); }
              public function slepenStop(e:MouseEvent):void { Hitte_mc.stopDrag(); }
              public function verdwijnen (e:Event) {
                   if (e.target.hitTestObject(Hitte_mc)) {
                        e.target.alpha += -0.1;
                   if (e.target.alpha <= 0.1 && e.target.alpha > 0) {
                        e.target.alpha = 0;
                        verwijderd += 1;

  • Help with a hangman class with Gui

    Gah, so I'm creating a Java Hangman program using a gui program. Everything was working fine till I started adding the program to the gui. I'm hopelessly confused, and I can't seem to get it working. Help appreciated! Thanks guys... I'm really bad at this, sorry for the noob question.
    import java.awt.BorderLayout;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.io.File;
    import java.util.Random;
    import java.util.Scanner;
    import javax.accessibility.AccessibleContext;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.plaf.PanelUI;
    public class hmg extends JPanel {
         private char[] word;
         private int Misses;
         private int myWordIndex;
         private int index;
         private boolean[] used;
         protected Image[] i = new Image[8];
         protected Image[] s = new Image[3];
         private final static char NADA = '_';
         private final static int GUESSES = 8;
         private String fileName;
              i[0] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang1.jpg");
              i[1] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang2.jpg");
              i[2] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang3.jpg");
              i[3] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hange4.jpg");
              i[4] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang5.jpg");
              i[5] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang6.jpg");
              i[6] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang7.jpg");
              i[7] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang8.jpg");
              s[0] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hacks.jpg");
              s[1] = Toolkit.getDefaultToolkit().getImage(
              "C:\\Documents and Settings\\mfleming\\Desktop\\hacks.jpg");
              s[2] = Toolkit.getDefaultToolkit().getImage(
              "C:\\Documents and Settings\\mfleming\\Desktop\\hacks.jpg");
         protected int x = 0;
         protected ImageIcon icon = new ImageIcon(i[x++]);
         protected ImageIcon icon2 = new ImageIcon(s[x++]);
         private JLabel j = new JLabel(icon);
         private JButton b = new JButton();
         private JLabel a = new JLabel();
         private String[] wordArray;
         private String wordChosen;
         public void paintComponent(Graphics g) {
              super.paintComponents(g);
         public hmg() {
              this.add(j);
              JButton guess = new JButton("The Click of Faith!");
              this.add(guess, BorderLayout.WEST);
              guess.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        if (!(x == i.length)) {
                             icon = new ImageIcon(i[x++]);
                             j.setIcon(icon);
              JButton guess2 = new JButton("Click here if your almost dead! ");
              this.add(guess2, BorderLayout.WEST);
              guess2.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        icon2 = new ImageIcon(s[x++]);
                        j.setIcon(icon);
              this.add(a, BorderLayout.SOUTH);
              a.setText(showWord());
              a.setText(play());
              Misses = 0;
              index = 0;
              used = new boolean[Character.MAX_VALUE];
         //     public void actionPerformed(ActionEvent arg0) {
         //          if (!(x == i.length)) {
         //          icon = new ImageIcon(i[x++]);
         //          j.setIcon(icon);
         private void clear() {
              int k;
              for (k = 0; k < Character.MAX_VALUE; k++) {
                   used[k] = false;
              word = new char[myWords[myWordIndex].length()];
              for (k = 0; k < word.length; k++) {
                   word[k] = NADA;
         private void guess(char ch) {
              int b;
              boolean charFound = false;
              ch = Character.toLowerCase(ch);
              for (b = 0; b < word.length; b++) {
                   if (!used[ch] && myWords[index].charAt(b) == ch) {
                        word[b] = ch;
                        charFound = true;
              if (!used[ch] && !charFound) {
                   Misses++;
              used[ch] = true;
         private void chooseRandomWord()
         // myWords[];
    //     loadFileList();
              Random generator = new Random();
              int x = generator.nextInt(wordArray.length);
              wordChosen = wordArray[x];
         //public void processFile(String commonWords) {
         //     wordArray = commonWords.split(",");
         //private String[] loadFileList() {
         //     try
         //          fileName = "C:\\Documents and Settings\\mfleming\\Desktop\\Wordlist";
         //               File file = new File("C:\\Documents and
         // Settings\\mfleming\\Desktop\\Wordlist");
         //          if(file.exists());
         //               Scanner scan = new Scanner(file);
         //               while(scan.hasNext())
         //                    String word = scan.next();
         //                    processFile(word);
         //     } catch (Exception e)
         //          e.printStackTrace();
         //     return wordArray;
         //     public void add() {
         //          try {
         //               Scanner s = new Scanner(new File("Wordlist"));
         //               while (s.hasNext())
         //          } catch (Exception e) {
         private String showWord() {
              int k;     
              String temp = "";
              for (k = 0; k < word.length; k++) {
                   temp +=word[k];
    //               System.out.print(word[k] + " ");
              return temp;
              //                    return showWord();
    //          System.out.println(" \nYou have exactly " + (GUESSES - Misses)
    //                    + " guesses left! Time is running out! Cue Music LOL ");
         private boolean wordGuessed() {
              int a;
              for (a = 0; a < word.length; a++) {
                   if (word[a] == NADA) {
                        return false;
              return true;
         // .setIcon --- Put image.
         public String play() {
              clear();
              String temp = "";
              while (true) {
    //               showWord();
                   a.setText(showWord());
                   //May not have to return string.
    //               System.out
    //                         .print("Your guess shall be? 1234567890abcdefhijklmnopqrstuvqxyz hA! Guess... it's simply up to you!");
                   String s = Blah.readString();
                   if (s.length() > 0) {
                        guess(s.charAt(0));
                   if (Misses >= GUESSES) {
    //                    System.out.println("You killed your hangman because....");
                        //                    System.out.println(storeWord);
                        break;
                   } else if (wordGuessed()) {
    //                    System.out.println("You win. You suck. LOL. ><");
    //                    System.out.println(word);
                        break;
              index = (index + 1) / myWords.length;
              return temp;
         //     public String storeWord() {
         //          return SW;
         public static final void main(String args[]) {
              hmg hmg = new hmg();
              hmg.play();
         private class MousePressedListener implements MouseListener {
              public void mousePressed(MouseEvent e) {
                   if (e.getButton() == e.BUTTON1) {
                        ((JButton) e.getSource()).setText("X");
                   if (e.getButton() == e.BUTTON3) {
                        ((JButton) e.getSource()).setText("O");
              * (non-Javadoc)
              * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
              public void mouseClicked(MouseEvent arg0) {
                   // TODO Auto-generated method stub
              * (non-Javadoc)
              * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
              public void mouseEntered(MouseEvent arg0) {
                   // TODO Auto-generated method stub
              * (non-Javadoc)
              * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
              public void mouseExited(MouseEvent arg0) {
                   // TODO Auto-generated method stub
              * (non-Javadoc)
              * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
              public void mouseReleased(MouseEvent arg0) {
                   // TODO Auto-generated method stub
         * (non-Javadoc)
         * @see java.awt.Component#getAccessibleContext()
         public AccessibleContext getAccessibleContext() {
              // TODO Auto-generated method stub
              return super.getAccessibleContext();
         * (non-Javadoc)
         * @see javax.swing.JPanel#getUI()
         public PanelUI getUI() {
              // TODO Auto-generated method stub
              return super.getUI();
         * (non-Javadoc)
         * @see javax.swing.JComponent#getUIClassID()
         public String getUIClassID() {
              // TODO Auto-generated method stub
              return super.getUIClassID();
         * (non-Javadoc)
         * @see java.awt.Component#paramString()
         protected String paramString() {
              // TODO Auto-generated method stub
              return super.paramString();
         * (non-Javadoc)
         * @see javax.swing.JPanel#setUI(javax.swing.plaf.PanelUI)
         public void setUI(PanelUI arg0) {
              // TODO Auto-generated method stub
              super.setUI(arg0);
         * (non-Javadoc)
         * @see javax.swing.JComponent#updateUI()
         public void updateUI() {
              // TODO Auto-generated method stub
              super.updateUI();
         private String myWords[] = { "analysis", "approach", "area", "assessment",
                   "assume", "authority     ", "available", "benefit ", "concept ",
                   "consistent", "constitutional", "context", "contract", "create",
                   "data", "definition", "derived ", "distribution ", "economic",
                   "environment ", "established", "estimate ", "evidence", "export",
                   "factors", "financial", "formula", "function", "identified",
                   "income", "indicate ", "individual ", "interpretation",
                   "involved", "issues", "labour", "legal", "legislation", "major ",
                   "method", "occur", "percent ", "period", "policy", "principle",
                   "procedure", "process", "required", "research", "response", "role",
                   "section", "sector", "significant ", "similar", "source",
                   "specific", "structure", "theory", "variables", "achieve ",
                   "acquisition", "administration ", "affect", "appropriate ",
                   "aspects", "assistance ", "categories", "chapter", "commission",
                   "community", "complex ", "computer ", "conclusion", "conduct",
                   "consequences", "construction", "consumer ", "credit", "cultural ",
                   "design", "distinction", "elements ", "equation", "evaluation ",
                   "features ", "final", "focus", "impact", "injury", "institute ",
                   "investment", "items", "journal ", "maintenance", "normal",
                   "obtained ", "participation", "perceived ", "positive ",
                   "potential", "previous", "primary ", "purchase ", "range ",
                   "region", "regulations", "relevant ", "resident", "resources",
                   "restricted ", "security ", "sought", "select", "site",
                   "strategies", "survey", "text", "traditional", "transfer",
                   "alternative", "circumstances ", "comments", "compensation",
                   "components", "consent", "considerable", "constant ",
                   "constraints", "contribution", "convention ", "coordination",
                   "core", "corporate ", "corresponding", "criteria", "deduction",
                   "demonstrate ", "document", "dominant", "emphasis ", "ensure",
                   "excluded", "framework ", "funds", "illustrated ", "immigration",
                   "implies", "initial ", "instance ", "interaction", "justification",
                   "layer", "link", "location", "maximum ", "minorities", "negative ",
                   "outcomes", "partnership", "philosophy ", "physical ",
                   "proportion ", "published ", "reaction", "registered ", "reliance",
                   "removed", "scheme", "sequence", "sex", "shift", "specified ",
                   "sufficient", "task", "technical ", "techniques", "technology",
                   "validity", "volume", "access", "adequate", "annual", "apparent",
                   "approximated", "attitudes ", "attributed ", "civil", "code",
                   "commitment ", "communication", "concentration", "conference ",
                   "contrast ", "cycle", "debate", "despite ", "dimensions ",
                   "domestic ", "emerged ", "error", "ethnic", "goals", "granted",
                   "hence", "hypothesis ", "implementation", "implications",
                   "imposed", "integration", "internal ", "investigation", "job",
                   "label", "mechanism ", "obvious", "occupational ", "option",
                   "output", "overall ", "parallel", "parameters", "phase",
                   "predicted", "principal", "prior", "professional", "project",
                   "promote", "regime", "resolution ", "retained", "series",
                   "statistics ", "status", "stress", "subsequent", "sum", "summary",
                   "undertaken ", "academic ", "adjustment ", "alter ", "amendment ",
                   "aware ", "capacity ", "challenge ", "clause ", "compounds ",
                   "conflict ", "consultation ", "contact ", "decline ",
                   "discretion ", "draft ", "enable ", "energy ", "enforcement ",
                   "entities ", "equivalent ", "evolution ", "expansion ",
                   "exposure ", "external ", "facilitate ", "fundamental ",
                   "generated ", "generation ", "image ", "liberal", "licence ",
                   "logic ", "marginal ", "medical ", "mental ", "modified ",
                   "monitoring ", "network ", "notion ", "objective ", "orientation ",
                   "perspective ", "precise ", "prime ", "psychology ", "pursue ",
                   "ratio ", "rejected ", "revenue ", "stability ", "styles ",
                   "substitution ", "sustainable", "symbolic ", "target ",
                   "transition ", "trend ", "version ", "welfare ", "whereas ",
                   "abstract ", "accurate ", "acknowledged ", "aggregate ",
                   "allocation ", "assigned ", "attached ", "author ", "bond ",
                   "brief ", "capable ", "cited ", "cooperative ", "discrimination ",
                   "display ", "diversity ", "domain ", "edition ", "enhanced ",
                   "estate ", "exceed ", "expert ", "explicit ", "federal ", "fees ",
                   "flexibility ", "furthermore ", "gender ", "ignored ",
                   "incentive ", "incidence ", "incorporated ", "index ",
                   "inhibition ", "initiatives ", "input ", "instructions ",
                   "intelligence ", "interval ", "lecture ", "migration ", "minimum ",
                   "ministry ", "motivation ", "neutral ", "nevertheless ",
                   "overseas ", "preceding ", "presumption ", "rational ",
                   "recovery ", "revealed ", "scope ", "subsidiary ", "tapes ",
                   "trace ", "transformation ", "transport ", "underlying ",
                   "utility ", "adaptation ", "adults ", "advocate ", "aid ",
                   "channel ", "chemical", "classical ", "comprehensive ",
                   "comprise ", "confirmed ", "contrary ", "converted ", "couple ",
                   "decades ", "definite", "deny ", "differentiation ", "disposal ",
                   "dynamic ", "eliminate ", "empirical ", "equipment ", "extract ",
                   "file ", "finite ", "foundation ", "global ", "grade ",
                   "guarantee ", "hierarchical ", "identical ", "ideology ",
                   "inferred ", "innovation ", "insert ", "intervention ",
                   "isolated ", "media ", "mode ", "paradigm ", "phenomenon ",
                   "priority ", "prohibited ", "publication ", "quotation ",
                   "release ", "reverse ", "simulation ", "solely ", "somewhat ",
                   "submitted ", "successive ", "survive ", "thesis ", "topic ",
                   "transmission ", "ultimately ", "unique ", "visible ",
                   "voluntary ", "abandon ", "accompanied ", "accumulation ",
                   "ambiguous ", "appendix ", "appreciation ", "arbitrary ",
                   "automatically ", "bias ", "chart ", "clarity", "conformity ",
                   "commodity ", "complement ", "contemporary ", "contradiction ",
                   "crucial ", "currency ", "denote ", "detected ", "deviation ",
                   "displacement ", "dramatic ", "eventually ", "exhibit ",
                   "exploitation ", "fluctuations ", "guidelines ", "highlighted ",
                   "implicit ", "induced ", "inevitably ", "infrastructure ",
                   "inspection ", "intensity ", "manipulation ", "minimised ",
                   "nuclear ", "offset ", "paragraph ", "plus ", "practitioners ",
                   "predominantly ", "prospect ", "radical ", "random ",
                   "reinforced ", "restore ", "revision ", "schedule ", "tension ",
                   "termination ", "theme ", "thereby ", "uniform ", "vehicle ",
                   "via ", "virtually ", "widespread ", "visual ", "accommodation ",
                   "analogous ", "anticipated ", "assurance ", "attained ", "behalf ",
                   "bulk ", "ceases ", "coherence ", "coincide ", "commenced ",
                   "incompatible ", "concurrent ", "confined ", "controversy ",
                   "conversely ", "device ", "devoted ", "diminished ", "distorted",
                   "distortion", "equal", "figures", "duration ", "erosion ",
                   "ethical ", "format ", "founded ", "inherent ", "insights ",
                   "integral ", "intermediate ", "manual ", "mature ", "mediation ",
                   "medium ", "military ", "minimal ", "mutual ", "norms ",
                   "overlap ", "passive ", "portion ", "preliminary ", "protocol ",
                   "qualitative ", "refine ", "relaxed ", "restraints ",
                   "revolution ", "rigid ", "route ", "scenario ", "sphere ",
                   "subordinate ", "supplementary ", "suspended ", "team ",
                   "temporary ", "trigger ", "unified ", "violation ", "vision ",
                   "adjacent ", "albeit ", "assembly ", "collapse ", "colleagues ",
                   "compiled ", "conceived ", "convinced ", "depression ",
                   "encountered ", "enormous ", "forthcoming ", "inclination ",
                   "integrity ", "intrinsic ", "invoked ", "levy ", "likewise ",
                   "nonetheless ", "notwithstanding ", "odd ", "ongoing ", "panel ",
                   "persistent ", "posed ", "reluctant ", "straightforward ",
                   "undergo ", "whereby ", "noob", "frag", "punish", "lamer", "noobs",
                   "knife", "shank", "humvee", "sniper", "don't", "run", "you'll",
                   "only", "die", "tired", "LOL", "ROFL", "GG", "FTW", "indeed",
                   "sure", "yeah", "yea", "hi", "hello", };
    DRIVER CLASS
    import java.awt.BorderLayout;
    import java.awt.Container;
    import javax.swing.JFrame;
    public class HangManGuiTest {
         public static void main(String[] args) {
    //          hangmangui hmg = new hangmangui();
              hmg hmg = new hmg();
              JFrame frame = new JFrame("Hangman! DJ Joker[8]Baller");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setContentPane(hmg);
              frame.pack();
              frame.show();
    //          JFrame j = new JFrame();
    //          Listeners - Control everything - Call stuff from hmg.
    //          frame.getContentPane().add(hmg);
    //          j.setSize(500, 500);
    //          j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //          j.setVisible(true);
              hmg.play();
    Message was edited by:
    joker8baller

    Hey! Thanks for the tip...
    Anyways, I fixed all of the errors (T hank god) and now all I have t o do is add the text to the gui. Help for adding the text into the gui. When I run it, it runs a gui, and it shows the spaces, but when I put in input.. nothing shows up and nothing plays.
    So I'm going to use a.setText... for showWord and and play()... Is there anything else I woiuld need to do?
    import java.awt.BorderLayout;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.io.File;
    import java.util.Random;
    import java.util.Scanner;
    import javax.accessibility.AccessibleContext;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.plaf.PanelUI;
    public class hmg extends JPanel {
         private char[] word;
         private int Misses;
         private int myWordIndex;
         private int index;
         private boolean[] used;
         protected Image[] i = new Image[8];
         protected Image[] s = new Image[3];
         private final static char NADA = '_';
         private final static int GUESSES = 8;
         private String fileName;
              i[0] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang1.jpg");
              i[1] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang2.jpg");
              i[2] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang3.jpg");
              i[3] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hange4.jpg");
              i[4] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang5.jpg");
              i[5] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang6.jpg");
              i[6] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang7.jpg");
              i[7] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang8.jpg");
              s[0] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hacks.jpg");
              s[1] = Toolkit.getDefaultToolkit().getImage(
              "C:\\Documents and Settings\\mfleming\\Desktop\\hacks.jpg");
              s[2] = Toolkit.getDefaultToolkit().getImage(
              "C:\\Documents and Settings\\mfleming\\Desktop\\hacks.jpg");
         protected int x = 0;
         protected ImageIcon icon = new ImageIcon(i[x++]);
         protected ImageIcon icon2 = new ImageIcon(s[x++]);
         private JLabel j = new JLabel(icon);
         private JButton b = new JButton();
         private JLabel a = new JLabel();
         private String[] wordArray;
         private String wordChosen;
         public void paintComponent(Graphics g) {
              super.paintComponents(g);
         public hmg() {
              this.add(j);
              JButton guess = new JButton("The Click of Faith!");
              this.add(guess, BorderLayout.WEST);
              guess.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        if (!(x == i.length)) {
                             icon = new ImageIcon(i[x++]);
                             j.setIcon(icon);
              JButton guess2 = new JButton("Click here if your almost dead! ");
              this.add(guess2, BorderLayout.WEST);
              guess2.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        icon2 = new ImageIcon(s[x++]);
                        j.setIcon(icon);
    //          this.add(a, BorderLayout.SOUTH);
    //          a.setText(clear());
    //          a.setText(showWord());
    //          a.setText(play());
              Misses = 0;
              index = 0;
              used = new boolean[Character.MAX_VALUE];
         //     public void actionPerformed(ActionEvent arg0) {
         //          if (!(x == i.length)) {
         //          icon = new ImageIcon(i[x++]);
         //          j.setIcon(icon);
         private void clear() {
              int k;
              for (k = 0; k < Character.MAX_VALUE; k++) {
                   used[k] = false;
              word = new char[myWords[myWordIndex].length()];
              System.out.println(word.length);
              for (k = 0; k < word.length; k++) {
                   word[k] = NADA;
         private void guess(char ch) {
              int b;
              boolean charFound = false;
              ch = Character.toLowerCase(ch);
              for (b = 0; b < word.length; b++) {
                   if (!used[ch] && myWords[index].charAt(b) == ch) {
                        word[b] = ch;
                        charFound = true;
              if (!used[ch] && !charFound) {
                   Misses++;
              used[ch] = true;
         private void chooseRandomWord()
         // myWords[];
    //      loadFileList();
              Random generator = new Random();
              int x = generator.nextInt(wordArray.length);
              wordChosen = wordArray[x];
         //public void processFile(String commonWords) {
         //     wordArray = commonWords.split(",");
         //private String[] loadFileList() {
         //     try
         //          fileName = "C:\\Documents and Settings\\mfleming\\Desktop\\Wordlist";
         //               File file = new File("C:\\Documents and
         // Settings\\mfleming\\Desktop\\Wordlist");
         //          if(file.exists());
         //               Scanner scan = new Scanner(file);
         //               while(scan.hasNext())
         //                    String word = scan.next();
         //                    processFile(word);
         //     } catch (Exception e)
         //          e.printStackTrace();
         //     return wordArray;
         //     public void add() {
         //          try {
         //               Scanner s = new Scanner(new File("Wordlist"));
         //               while (s.hasNext())
         //          } catch (Exception e) {
         private String showWord() {
              int k;     
              String temp = "";
              for (k = 0; k < word.length; k++) {
                   temp +=word[k];
    //               System.out.print(word[k] + " ");
              return temp;
              //                    return showWord();
    //          System.out.println(" \nYou have exactly " + (GUESSES - Misses)
    //                    + " guesses left! Time is running out! Cue Music LOL ");
         private boolean wordGuessed() {
              int a;
              for (a = 0; a < word.length; a++) {
                   if (word[a] == NADA) {
                        return false;
              return true;
         // .setIcon --- Put image.
         public String play() {
              clear();
              String temp = "";
              while (true) {
    //               showWord();
                   a.setText(showWord());
                   //May not have to return string.
         JOptionPane.showInputDialog("Your guess shall be? 1234567890abcdefhijklmnopqrstuvqxyz hA! Guess... its simply up to you!");
    //               System.out
    //                         .print("Your guess shall be? 1234567890abcdefhijklmnopqrstuvqxyz hA! Guess... it's simply up to you!");
                   String s = Blah.readString();
                   if (s.length() > 0) {
                        guess(s.charAt(0));
                   if (Misses >= GUESSES) {
                        JOptionPane.showMessageDialog(null,"You killed your hangman because....");
    //                    System.out.println("You killed your hangman because....");
                        //                    System.out.println(storeWord);
                        break;
                   } else if (wordGuessed()) {
                        JOptionPane.showMessageDialog(null, "You win. You suck. LOL. ><");
    //                    System.out.println("You win. You suck. LOL. ><");
    //                    System.out.println(word);
                        break;
              index = (index + 1) / myWords.length;
              return temp;
         //     public String storeWord() {
         //          return SW;
         public static final void main(String args[]) {
              hmg hmg = new hmg();
              hmg.play();
               * (non-Javadoc)
               * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
              public void mouseClicked(MouseEvent arg0) {
                   // TODO Auto-generated method stub
               * (non-Javadoc)
               * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
              public void mouseEntered(MouseEvent arg0) {
                   // TODO Auto-generated method stub
               * (non-Javadoc)
               * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
              public void mouseExited(MouseEvent arg0) {
                   // TODO Auto-generated method stub
               * (non-Javadoc)
               * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
              public void mouseReleased(MouseEvent arg0) {
                   // TODO Auto-generated method stub
          * (non-Javadoc)
          * @see java.awt.Component#getAccessibleContext()
         public AccessibleContext getAccessibleContext() {
              // TODO Auto-generated method stub
              return super.getAccessibleContext();
          * (non-Javadoc)
          * @see javax.swing.JPanel#getUI()
         public PanelUI getUI() {
              // TODO Auto-generated method stub
              return super.getUI();
          * (non-Javadoc)
          * @see javax.swing.JComponent#getUIClassID()
         public String getUIClassID() {
              // TODO Auto-generated method stub
              return super.getUIClassID();
          * (non-Javadoc)
          * @see java.awt.Component#paramString()
         protected String paramString() {
              // TODO Auto-generated method stub
              return super.paramString();
          * (non-Javadoc)
          * @see javax.swing.JPanel#setUI(javax.swing.plaf.PanelUI)
         public void setUI(PanelUI arg0) {
              // TODO Auto-generated method stub
              super.setUI(arg0);
          * (non-Javadoc)
          * @see javax.swing.JComponent#updateUI()
         public void updateUI() {
              // TODO Auto-generated method stub
              super.updateUI();
         private String myWords[] = { "approach", "area", "assessment",
                   "assume", "authority     ", "available", "benefit ", "concept ",
                   "consistent", "constitutional", "context", "contract", "create",
                   "data", "definition", "derived ", "distribution ", "economic",
                   "environment ", "established", "estimate ", "evidence", "export",
                   "factors", "financial", "formula", "function", "identified",
                   "income", "indicate ", "individual  ", "interpretation",
                   "involved", "issues", "labour", "legal", "legislation", "major ",
                   "method", "occur", "percent ", "period", "policy", "principle",
                   "procedure", "process", "required", "research", "response", "role",
                   "section", "sector", "significant  ", "similar", "source",
                   "specific", "structure", "theory", "variables", "achieve ",
                   "acquisition", "administration  ", "affect", "appropriate ",
                   "aspects", "assistance ", "categories", "chapter", "commission",
                   "community", "complex ", "computer ", "conclusion", "conduct",
                   "consequences", "construction", "consumer ", "credit", "cultural ",
                   "design", "distinction", "elements ", "equation", "evaluation ",
                   "features ", "final", "focus", "impact", "injury", "institute ",
                   "investment", "items", "journal ", "maintenance", "normal",
                   "obtained ", "participation", "perceived ", "positive ",
                   "potential", "previous", "primary ", "purchase ", "range ",
                   "region", "regulations", "relevant ", "resident", "resources",
                   "restricted ", "security ", "sought", "select", "site",
                   "strategies", "survey", "text", "traditional", "transfer",
                   "alternative", "circumstances ", "comments", "compensation",
                   "components", "consent", "considerable", "constant ",
                   "constraints", "contribution", "convention ", "coordination",
                   "core", "corporate ", "corresponding", "criteria", "deduction",
                   "demonstrate ", "document", "dominant", "emphasis ", "ensure",
                   "excluded", "framework ", "funds", "illustrated ", "immigration",
                   "implies", "initial ", "instance ", "interaction", "justification",
                   "layer", "link", "location", "maximum ", "minorities", "negative ",
                   "outcomes", "partnership", "philosophy ", "physical ",
                   "proportion ", "published ", "reaction", "registered ", "reliance",
                   "removed", "scheme", "sequence", "sex", "shift", "specified ",
                   "sufficient", "task", "technical ", "techniques", "technology",
                   "validity", "volume", "access", "adequate", "annual", "apparent",
                   "approximated", "attitudes ", "attributed ", "civil", "code",
                   "commitment ", "communication", "concentration", "conference ",
                   "contrast ", "cycle", "debate", "despite ", "dimensions ",
                   "domestic ", "emerged ", "error", "ethnic", "goals", "granted",
                   "hence", "hypothesis ", "implementation", "implications",
                   "imposed", "integration", "internal ", "investigation", "job",
                   "label", "mechanism ", "obvious", "occupational ", "option",
                   "output", "overall ", "parallel", "parameters", "phase",
                   "predicted", "principal", "prior", "professional", "project",
                   "promote", "regime", "resolution ", "retained", "series",
                   "statistics ", "status", "stress", "subsequent", "sum", "summary",
                   "undertaken ", "academic ", "adjustment ", "alter ", "amendment ",
                   "aware ", "capacity ", "challenge ", "clause ", "compounds ",
                   "conflict ", "consultation ", "contact ", "decline ",
                   "discretion ", "draft ", "enable ", "energy ", "enforcement ",
                   "entities ", "equivalent ", "evolution ", "expansion ",
                   "exposure ", "external ", "facilitate ", "fundamental ",
                   "generated ", "generation ", "image ", "liberal", "licence ",
                   "logic ", "marginal ", "medical ", "mental ", "modified ",
                   "monitoring ", "network ", "notion ", "objective ", "orientation ",
                   "perspective ", "precise ", "prime ", "psychology ", "pursue ",
                   "ratio ", "rejected ", "revenue ", "stability ", "styles ",
                   "substitution ", "sustainable", "symbolic ", "target ",
                   "transition ", "trend ", "version ", "welfare ", "whereas ",
                   "abstract ", "accurate ", "acknowledged ", "aggregate ",
                   "allocation ", "assigned ", "attached ", "author ", "bond ",
                   "brief ", "capable ", "cited ", "cooperative ", "discrimination ",
                   "display ", "diversity ", "domain ", "edition ", "enhanced ",
                   "estate ", "exceed ", "expert ", "explicit ", "federal ", "fees ",
                   "flexibility ", "furthermore ", "gender ", "ignored ",
                   "incentive ", "incidence ", "incorporated ", "index ",
                   "inhibition ", "initiatives ", "input ", "instructions ",
                   "intelligence ", "interval ", "lecture ", "migration ", "minimum ",
                   "ministry ", "motivation ", "neutral ", "nevertheless ",
                   "overseas ", "preceding ", "presumption ", "rational ",
                   "recovery ", "revealed ", "scope ", "subsidiary ", "tapes ",
                   "trace ", "transformation ", "transport ", "underlying ",
                   "utility ", "adaptation ", "adults ", "advocate ", "aid ",
                   "channel ", "chemical", "classical ", "comprehensive ",
                   "comprise ", "confirmed ", "contrary ", "converted ", "couple ",
                   "decades ", "definite", "deny ", "differentiation ", "disposal ",
                   "dynamic ", "eliminate ", "empirical ", "equipment ", "extract ",
                   "file ", "finite ", "foundation ", "global ", "grade ",
                   "guarantee ", "hierarchical ", "identical ", "ideology ",
                   "inferred ", "innovation ", "insert ", "intervention ",
                   "isolated ", "media ", "mode ", "paradigm ", "phenomenon ",
                   "priority ", "prohibited ", "publication ", "quotation ",
                   "release ", "reverse ", "simulation ", "solely ", "somewhat ",
                   "submitted ", "successive ", "survive ", "thesis ", "topic ",
                   "transmission ", "ultimately ", "unique ", "visible ",
                   "voluntary ", "abandon ", "accompanied ", "accumulation ",
                   "ambiguous ", "appendix ", "appreciation ", "arbitrary ",
                   "automatically ", "bias ", "chart ", "clarity", "conformity ",
                   "commodity ", "complement ", "contemporary ", "contradiction ",
                   "crucial ", "currency ", "denote ", "detected ", "deviation ",
                   "displacement ", "dramatic ", "eventually ", "exhibit ",
                   "exploitation ", "fluctuations ", "guidelines ", "highlighted ",
                   "implicit ", "induced ", "inevitably ", "infrastructure ",
                   "inspection ", "intensity ", "manipulation ", "minimised ",
                   "nuclear ", "offset ", "paragraph ", "plus ", "practitioners ",
                   "predominantly ", "prospect ", "radical ", "random ",
                   "reinforced ", "restore ", "revision ", "schedule ", "tension ",
                   "termination ", "theme ", "thereby ", "uniform ", "vehicle ",
                   "via ", "virtually ", "widespread ", "visual ", "accommodation ",
                   "analogous ", "anticipated ", "assurance ", "attained ", "behalf ",
                   "bulk ", "ceases ", "coherence ", "coincide ", "commenced ",
                   "incompatible ", "concurrent ", "confined ", "controversy ",
                   "conversely ", "device ", "devoted ", "diminished ", "distorted",
                   "distortion", "equal", "figures", "duration ", "erosion ",
                   "ethical ", "format ", "founded ", "inherent ", "insights ",
                   "integral ", "intermediate ", "manual ", "mature ", "mediation ",
                   "medium ", "military ", "minimal ", "mutual ", "norms ",
                   "overlap ", "passive ", "portion ", "preliminary ", "protocol ",
                   "qualitative ", "refine ", "relaxed ", "restraints ",
                   "revolution ", "rigid ", "route ", "scenario ", "sphere ",
                   "subordinate ", "supplementary ", "suspended ", "team ",
                   "temporary ", "trigger ", "unified ", "violation ", "vision ",
                   "adjacent ", "albeit ", "assembly ", "collapse ", "colleagues ",
                   "compiled ", "conceived ", "convinced ", "depression ",
                   "encountered ", "enormous ", "forthcoming ", "inclination ",
                   "integrity ", "intrinsic ", "invoked ", "levy ", "likewise ",
                   "nonetheless ", "notwithstanding ", "odd ", "ongoing ", "panel ",
                   "persistent ", "posed ", "reluctant ", "straightforward ",
                   "undergo ", "whereby ", "noob", "frag", "punish", "lamer", "noobs",
                   "knife", "shank", "humvee", "sniper", "don't", "run", "you'll",
                   "only", "die", "tired", "LOL", "ROFL", "GG", "FTW", "indeed",
                   "sure", "yeah", "yea", "hi", "hello", };
    }Message was edited by:
    joker8baller

  • Problem with compiling a class with a package

    Hello,
    I am trying to implement the package example from the SUN Tutorial. It can be found on the page: http://java.sun.com/docs/books/tutorial/java/interpack/QandE/packages-questions.html
    I think I am doing like described but it doesn�t work. The files are stored like following on my machine:
    C:\mygame\Shared\Utilities.java               (this file can be compiled)
    C:\mygame\Server\Server.java                    (can�t be compiled)
    C:\mygame\Client\Client.java                    (can�t be compiled)
    I have no CLASSPATH set (but I tried), Java is installed in C:\Java\j2sdk
    If I try to compile the file Client.java with javac the following error message occurs:
    C:\mygame\Client>javac Client.java
    Client.java:7: cannot resolve symbol
    symbol : class Utilities
    location: package shared
    import mygame.shared.Utilities;
    ^
    Client.java:23: cannot resolve symbol
    symbol : variable Utilities
    location: class mygame.client.Client
    Utilities.printMsg("creating output stream");
    ^
    Client.java:32: cannot resolve symbol
    symbol : variable Utilities
    location: class mygame.client.Client
    Utilities.printMsg("writing current date");
    ^
    3 errors
    Are there any further prerequisites?
    Thank you

    Thank you for helping me. Now I am one step forward. Now I can compile each of my Java classes. But if I want to start them with java the following messages occurs. In addition I changed all pathes and class names to lower case.
    C:\mygame\server>java server
    Exception in thread "main" java.lang.NoClassDefFoundError: server
    C:\mygame\server>cd ../client
    C:\mygame\client>java client
    Exception in thread "main" java.lang.NoClassDefFoundError: client
    C:\mygame\client>cd ../shared
    C:\mygame\shared>java utilities
    Exception in thread "main" java.lang.NoClassDefFoundError: utilities
    C:\mygame\shared>

  • Errors with CF 8.0.1 hotfix 3 and hotfix 4, "Object Instantiation Exception.Class not found"

    We need to get our servers up to date with the latest ColdFusion hotfixes in order to pass our security scans and policies. We have been following the Adobe instructions for installing the hotfixes, but we’re getting the same errors each time. The CF 8 hotfix 2 works fine, but once we install hotfix 3 and/or hotfix 4, we get the following errors:
    "Object Instantiation Exception.Class not found: coldfusion.security.ESAPIUtils The specific sequence of files included or processed is: C:\ColdFusion\wwwroot\WEB-INF\exception\java\lang\Exception.cfm, line: 12 "
    coldfusion.runtime.java.JavaObjectClassNotFoundException:
    We have dozens of servers running Windows XP, Netscape Enterprise Server 6.1 (I  know, don’t laugh), ColdFusion 8,0,1,195765, and Java Version 1.6.0_04. Just about  the only good thing about running XP on our servers is that it matches  our development boxes, so we have almost mirrored environments for dev,  test, and production. We do NOT have the CF install with the J2EE configuration.
    The crazy thing is, on tech note 51180 (http://kb2.adobe.com/cps/511/cpsid_51180.html), it says that the fix for bug # 71787 (Fix for "Object Instantiation Exception" thrown when calling a Java object constructor or method with a null argument under JDK 1.6.) was added in cumulative hotfix 2. However we don’t see this problem until we go to hotfix 3 (or 4).
    I’ve also been reading that other people had this same problem, and that the CF 8 hotfix 3 was not compatible with certain versions of JDK, then when you read the Adobe site for CF 8.0.1 hotfix 3, it says “Added the updated cumulative hotfix to make it compatible with jdk 1.4.x, 1.5.x and 1.6.x.”, so that makes me think that Adobe was supposed to have fixed this CF 8.0.1 hotfix 3 JDK incompatability issue - but unfortunately it's still not working for us. We have followed the instructions for removing the jar files and starting/restarting the CF server as directed, we’ve tried this 5-6 times, and still no luck.
    Recommendations? Seems like this is a ColdFusion bug to me – one that says is fixed on the Adobe site, but is not fixed in our environment. Please advise, thanks.

    For what it's worth, we had an MXUnit user describe a similar, though not identical, problem after installing the latest hotfixes. In his case, he's getting "NoSuchMethodExceptions".

  • Need help with Adobe Reader 11.0.0.8 and Group Policy Objects

    I am trying to deploy Adobe Reader 11.0.0.8 using Adobe Reader.
    I am using the AcroRead.msi I found in
    C:\Program Files (x86)\Adobe\Reader 11.0\Setup Files\{AC76BA86-7AD7-1033-7B44-AB0000000001}
    HOWEVER
    Instead of installing 11.0.0.8 it installs 11.0.0.0
    I have not had anyone complain about it asking for an update. But I'm sure it's only a matter of time. (I know about the customization which could prevent the updates, but I can't figure out how to get the correct version installed is the issue not the updates).
    So if I run the Setup.exe it ends up installing 11.0.0.8 but AcroRead.msi I think only installs 11.0.0.0
    Obviously you can't give a GPO an .exe so it's a closed loop. You can't use an .exe to install the proper version. And you can't install the proper version because you can't use an .exe
    You can only use the .msi which apparently only does 11.0.0.0
    I've been trying this that, have done jumping jacks and back flips trying to fix this (tried different versions, different approaches to this, nothing seems to work)
    Need some help. THIS IS WAYYYYYYY WAYYYYYYYYYYY Overcomplicated btw, shouldn't be this complicated for something so mundane.

    A couple of approaches and all involve a bit of work.
    Three steps:
    Do the install of the 11.0.0 MSI at the command line
    Then follow it with the 11.0.07 Updater MSP at the command line
    Finally the 11.0.08 Security Patch MSP at the command line.
    AIP
    Create the AIP from the three files above then then run the MSI from the command line.

  • Class /SAPSRM/CL_WF_PROCESS_LEVEL method IS_LAST_LEVEL not working

    We are running SRM 7.0 SP 8 with Process Controlled Workflow.
    I am trying to use object with reference to class /SAPSRM/CL_WF_PROCESS_LEVEL, method IS_LAST_LEVEL to determine if the current workflow process level is the last in an N-step approval. But the method does not return what I am expected, instead, it is always returning abap_true. I am puzzled for a while for this. Following is my code excerpt with this call:
            data:ls_process_level    type /sapsrm/s_wf_process_level,
                 lo_curr_proc_level  type ref to /sapsrm/cl_wf_process_level.
              call method /sapsrm/cl_wf_apv_facade=>get_current_process_level
                exporting
                  iv_document_guid = iv_doc_guid
                importing
                  es_process_level = ls_process_level.
              try.
                  lo_curr_proc_level = /sapsrm/cl_wf_process_level=>getpersistent_by_oid( ls_process_level-level_guid ).
                  if lo_curr_proc_level->is_last_level( ) eq 'X'.
                    lv_final_step = 'X'.
                  endif.
                catch cx_root.
                  raise exception type /sapsrm/cx_wf_not_found.
              endtry.
    Note: After the call to  /sapsrm/cl_wf_process_level=>getpersistent_by_oid, lo_curr_proc_level is returned with the actual valid object. The issue is only with the next call to IS_LAST_LEVEL.
    If you can shed some light as to what might be wrong with this code, OR, how else you would determine whether the current process level is the last step in an N-step approval, I'd really appreciate it.
    Thanks.

    Hi,
      Try the below code
      DATA lo_first_level           TYPE REF TO /sapsrm/cl_wf_process_level.
      DATA lo_temp_level            TYPE REF TO /sapsrm/cl_wf_process_level.
      DATA lo_obsolete_level        TYPE REF TO /sapsrm/cl_wf_process_level.
      DATA lv_process_status        TYPE /sapsrm/wf_process_status.
      DATA lo_process_config        TYPE REF TO /sapsrm/cl_wf_configuration.
      DATA lv_process_scheme        TYPE /sapsrm/wf_process_scheme.
      DATA lv_document_guid         TYPE /sapsrm/wf_document_guid.
      DATA lv_document_type         TYPE /sapsrm/wf_document_type.
      DATA lo_object_service        TYPE REF TO /sapsrm/cl_wf_object_service.
      DATA lo_runtime_config         TYPE REF TO /sapsrm/if_wf_runtime_hdl.
      DATA ls_config_value           TYPE /sapsrm/s_wf_runtime_result.
      DATA lv_config_value           TYPE /sapsrm/wf_conf_attr_val.
      DATA lv_restart_process_scheme TYPE /sapsrm/wf_process_scheme.
      DATA lv_first_level_id         TYPE os_guid.
      DATA lv_final_acceptance_registered TYPE /sapsrm/wf_conf_attr_val.
      CONSTANTS:
        lc_prc_level_class_name TYPE seoclskey VALUE '/SAPSRM/CL_WF_PROCESS_LEVEL',
        lc_scheme_attribute     TYPE /sapsrm/wf_conf_attr VALUE 'PRC_RSTSCE', " Process restart scheme
        lc_level_attribute      TYPE /sapsrm/wf_conf_attr VALUE 'PRC_RSTLVL'. " Process restart first level
      rv_updated = abap_false.
      lv_document_type = io_process->getdocument_type( ).
      lv_document_guid = io_process->getdocument_guid( ).
      CREATE OBJECT lo_object_service.
      CREATE OBJECT lo_process_config
        EXPORTING
          iv_document_type = lv_document_type
          iv_document_guid = lv_document_guid
          io_process       = io_process.
      lv_process_scheme = lo_process_config->get_process_scheme( ).
      IF lv_process_scheme EQ io_process->getprocess_scheme( ) AND iv_force_update EQ abap_false.
        RETURN.
      ENDIF.
      lv_process_status = /sapsrm/cl_wf_process_manager=>get_process_status( lv_document_guid ).
      "--- Get the OID of the first process level
      TRY.
          lo_runtime_config = /sapsrm/cl_wf_process_manager=>get_runtime_config(
            io_process = io_process
          IF lo_runtime_config IS NOT BOUND.
            RAISE EXCEPTION TYPE /sapsrm/cx_wf_abort.
          ENDIF.
          CLEAR ls_config_value.
          lo_runtime_config->get_attribute(
            EXPORTING
              iv_attribute = lc_level_attribute
            IMPORTING
              es_attribute_result = ls_config_value
          lv_first_level_id = ls_config_value-attribute_value.
        CATCH /sapsrm/cx_wf_error. "EC NO_HANDLER
          CLEAR ls_config_value.
      ENDTRY.
      "-- Get the Flag of FINAL_ACCEPTANCE_REGISTERED
      TRY .
          CLEAR ls_config_value.
          lo_runtime_config->get_attribute(
            EXPORTING
              iv_attribute = /sapsrm/if_wf_process_c=>gc_wf_runtime_attrib_010 "'ACP_FINAL'
            IMPORTING
              es_attribute_result = ls_config_value
          lv_final_acceptance_registered = ls_config_value-attribute_value.
        CATCH /sapsrm/cx_wf_error. "EC NO_HANDLER
          CLEAR ls_config_value..
      ENDTRY.
      "--- Determine current object state of the process instance
      IF ( lo_object_service->is_new_instance( io_process ) EQ abap_true OR
           lo_object_service->is_changed_instance( io_process ) EQ abap_true ) AND
         lv_process_status EQ /sapsrm/if_wf_process_c=>gc_process_status_initial.
        "--- Delete obsolete process levels in case process instance is still in initial state
        lo_temp_level = io_process->getfirst_level( ).
        DO.
          IF lo_temp_level IS NOT BOUND.
            EXIT.
          ENDIF.
         tif this field lo_temp_level->is_last_level( ) is 'X'
    Saravanan

  • PO with new account assignment category to G/L without CO object

    Hello all,
    A customer in a company I work for asked me to create a new account assignment category (AAC) with G/L account as mandatory field and no CO object as mandatory.
    He would like to create a PO with this AAC directly to balance-sheet account without any CO invloved (such as PO to stock) without a material.
    I have bad feelings about this process but I do not have anything substantial to convince him against it.
    Am I wrong ? Is this process allowed ? What "bad things" may happen if we use this process ?
    Any help will be appreciated,
    Thanks,
    Isaac

    Sir -
    These stuffs are done by many indian companies to inject some bad accounts. If this is a requirement, no choices left.
    It is possible to enter the material text and u can proceed with the things u need. You can create the value contract for this requirement.
    Thanks,
    Shiva

  • How to accept 2 strings in a class with try catch method..help!!

    the program below will accept two strings and compare str1 and str2 if equal. this program uses functions. can any one help me with this?
    import java.io.*;
    public class StrCompare {
         private BufferedReader takyoin = null;
         //private BufferedReader intakyo = null;
         * @param args
         public StrCompare(){
              takyoin = new BufferedReader(new InputStreamReader(System.in));
              //intakyo = new BufferedReader(new InputStreamReader(System.in));
         public String UserInput(){
         public static void main(String[] args) {
              // TODO Auto-generated method stub
    }

    What are you talking about? There is no such thing as "try-catch-methods", and there are no functions but methods.
    Strings by the way have their own means of comparision. Apart from that: do your own homework.

  • Abstract class with set and get methods

    hi
    how to write set and get methods(plain methods) in an abstartc class
    ex: setUsername(String)
    String getUsername()
    and one class is extending this abstract class and same methods existing in that sub class also..... how to write......plz provide some ideas
    am new to programming....
    asap
    thnx in advance

    yes... as i told u.... i am new to coding......
    and my problem is ..... i have 2 classes one is abstract class without abstract methods.. and another class is extending abstract class.....
    in abstract class i have 2 methods...one is setusername(string) and getusername() ..... how to write these two methods.... in abstract class i have private variables username...... when user logins ..... i need to catch the user name and i need to validate with my oracle database and i need to identify the role of that user and based on role of that user i need to direct him to appropriate jsp page.......
    for that now i am writing business process classes..... the above mentioned two classes are from business process.....
    could u help me now
    thnx in advance

  • Singleton class with static method

    Hi,
    I have made a fairly simple singletion class STClass. EX:
    Consider tow cases
    CASE-1:
    private static STClass singleInstance;
    private static int i;
    private STClass()
    public static STClass instance()
         if (singleInstance == null)
              singleInstance = new STClass();
              loadConfigFile("XYZ");
         return singleInstance;
    private static void loadConfigFile(String fileName)
         //SOME CODE in which use private variable "i"
    CASE-2:
    private static STClass singleInstance;
    private int i;
    private STClass()
         loadConfigFile("XYZ");
    public static STClass instance()
         if (singleInstance == null)
              singleInstance = new STClass();
         return singleInstance;
    private void loadConfigFile(String fileName)
         //SOME CODE in which use private variable "i"
    What is the differnce between two case and which one will be best and why???
    Someone told me "If u keep variables and methods as static the the whole purpose of singleton class is defeated"
    please justify this statement

    It seems to me that this way should be more "correct":
    public class STClass {
    private static STClass singleInstance;
    private int i;
    private STClass() {
    public static STClass getInstance() {
    if (singleInstance == null) {
    singleInstance = new STClass();
    singleInstance.loadConfigFile("XYZ");
    return singleInstance;
    private void loadConfigFile(String fileName) {
    //SOME CODE in which use private variable "i"
    }And it is also compatible with your CASE-2.
    Hope this helped,
    Regards.I wouldnot agree with this piece of code here because of JMM bug. check this
    http://www.javaworld.com/jw-02-2001/jw-0209-double-p2.html
    What about proposing your own version, explained ?...

  • Enhanced SAP class with new methods - Not showing these from standard task

    Dear Gurus,
    I have enhanced SAP standard class with new methods. After I have activated my new methods and would like to create a workflow task using these new methods. when I create a task and input object category as "ABAP Class" and object type is SAP enhanced class. When I try to drop down for methods SAP is not showing my new methods. I do not know why. Am I missing any? Any help would be appreciated.
    Note: Remember I am trying to use SAP ABAP class custom methods.
    Thanks,
    GSM

    Hi,
    Your thread has had no response since it's creation over
    2 weeks ago, therefore, I recommend that you either:
    - Rephrase the question.
    - Provide additional Information to prompt a response.
    - Close the thread if the answer is already known.
    Thank you for your compliance in this regard.
    Kind regards,
    Siobhan

  • HOWTO: Use the Spring data access methods together with the WebRowSet class

    With the WebRowSet class I can easily iterate over a ResultSet and produce some XML using the code below.
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection connection
    = DriverManager.getConnection("");
    Statement statement = connection.createStatement();
    ResultSet resultSet = statement.executeQuery("SELECT SYSDATE FROM DUAL");
    WebRowSet webRowSet = new WebRowSetImpl();
    webRowSet.populate(resultSet);
    statement.close();
    connection.close();
    webRowSet.writeXml(new FileOutputStream("C:\\SYSDATE.xml"));
    So, how would I use the simplified Spring methods to do the same thing? The WebRowSet.populate method only supports a ResultSet object. The Spring framework only returns an SqlRowSet object that is not easily cast to the ResultSet, etc.
    Thanks for your help.
    Edited by: mrmeth0d on Jan 3, 2008 2:02 PM

    So, how would I use the simplified Spring methods to do the same thing? The WebRowSet.populate method only supports a ResultSet object. The Spring framework only returns an SqlRowSet object that is not easily cast to the ResultSet, etc.
    Cast Spring's SqlRowSet to ResultSet? Impossible. It's an interface that does not extend java.sql.ResultSet.
    javax.sql.WebRowSet is an interface that extends java.sql.ResultSet.
    Spring does have a concrete class ResultSetWrappingSqlRowSet whose constructor can take a java.sql.ResultSet.
    So I think your solution is to instantiate a new ResultSetWrappingSqlRowSet, passing it your javax.sql.rowset.WebRowSet, and return that wherever Spring wants to return a SqlRowSet.
    %

  • Need help with User defined class

    I need to create two Java classes. The first class will be used as a template for objects which represent students, the second will be a program which creates two student object and calls some of their methods.
    Create a file called "Student.java" and in it definr a class called Student which has the following Attributes:
    * a String variable which can hold the student's name
    * a double variable which can hold the studnet's exam mark.
    In the student class, define public methods as follows:
    1 a constructor method which accepts no arguments. This method should initialise the student's name to "unknown" and set the examination mark to zero
    2 A constructor method which accepts 2 arguments- the first being a string representing the student's name and the other being a double which represents their exam mark. These arguments should be used to initialise the state variables with one proviso- the exam mark must not be set to a number outside the range 0...100. If the double argument is outside this range,set the exam mark attribute to 0.
    3 A reader method which returns the students name
    4 A reader method which returns the students exam mark.
    5 A writer method which sets the student's name
    6 A writer method which sets the student's eeam mark. If the exam mark argument is outside the the 0...100 range,the exam mark attibute should not be modified.
    7 A method which returns the studnet's grade. The grade is a string such as "HD" or "FL" which can be determined from the following table.
    Grade Exam Mark
    HD 85..100
    DI 75..84
    CR 65..74
    PS 50..64
    FL 0..49
    Part2 Client Code
    Write a program in a file called "TestStudent.java"
    Make sure the file is in the same directory as tne "Student.java" file
    In the main method of "TestStudent.java" write code to do each of the following tasks
    1 Create a student object using the no argument constructor.
    2 Print this student's name and their exam mark
    3 Create another student object using the other constructor-supply your own name as the string argument and whatever exam mark you like as the double argument
    4 Print this studnet's name and their exam mark
    5 Change the exam mark of this student to 50 and print their exam mark and grade.
    6 Change the examination mark of this studnet to 256 and print their exam mark and grade.
    Can someone please help
    goober

    Sorry, I have sent you the wrong version. Try this,
    public class Student {
         private String name;
         private double examMark;
         public Student() {
              name = "unknown";
              examMark = 0.0;
         public Student(String n, double em) {
              name = n;
              if(em >0 && em < 100) {
                   examMark = em;
              } else {
                   examMark = 0.0;
         public String getName() {
              return name;
         public void setName(String n) {
              name = n;
         public double getExamMark() {
              return examMark;
         public void setExamMark(double em) {
              if(em >0 && em < 100) {
                   examMark = em;
              } else {
                   examMark = 0.0;
         public String getGrade() {
              if ( examMark > 84) return "HD";
              else if(examMark > 74) return "DI";
              else if(examMark > 64) return "CR";
              else if(examMark > 49) return "PS";
              else return "FL";
    } and
    class TestStudent {
         public static void main(String a[]) {
              Student st = new Student();
              System.out.println("Student Name is : "+st.getName());
              System.out.println("Student Marks is : "+st.getExamMark());
              Student st1 = new Student("XXXX",78);
              System.out.println("Student Name is : "+st1.getName());
              System.out.println("Student Marks is : "+st1.getExamMark());
              st1.setExamMark(67);
              System.out.println("Student Marks is : "+st1.getExamMark());
              System.out.println("Student Grade is : "+st1.getGrade());
              st1.setExamMark(256);
              System.out.println("Student Marks is : "+st1.getExamMark());
              System.out.println("Student Grade is : "+st1.getGrade());
    }Hope this helps.
    Sudha

Maybe you are looking for

  • Subroutine  pass by value and result

    I actually wanted to know if the copying the value back to variable(inpu2) it works.but when i use stop staement to exit the subroutine the value is still copied back to the actual parameter input 2. plz guide me. REPORT  zsub_routines_pgm. DATA : in

  • NAM service will not start

    I am in the testing phase of the AnyConnect client. The network access manager will not start. In the system tray console, i see "service unavailable" for network:. When i try to start the nam service it says "the operation could not be completed. Ac

  • Dispatcher Not running for XI

    Hi Gurus, I have a XI 3.5 system with Oracle 10.2 Database. Errors 01) From MMC Dispatcher is not running 02) 'Work' Folder is also not accessible. Although the folder is showing almost 3.5 GB of Data but on clicking no files can be seen R3trans -d i

  • Machine hangs after every 30 min

    I have lonovo notebook,and am facing strange problem. the keyboard ,tap pad and pointer becomes unresponsive after every 30 minutes and i have to restart it to start work again. Also, it takes more than 5 minutes to start. I called the lenovo the sup

  • Can any one know how do restrict that fields in mm

    hi gurus can any one know how do we restrict the fields in the material master.  Where do we control  do any one know the transaction code for that. Thanks in advance