 |
|
 |
When posting your question please:- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers, Chris Maunder
The Code Project Co-fou
|
| Sign In·View Thread·PermaLink | 5.00/5 (4 votes) |
|
|
|
 |
|
 |
Errors im getting: cannot find symbol constructor method Token. but i do have a constructor in Token class
cannot find symbol variable tokenCode. i clearly use it alll over and i think i initialized it properly so whats wrong?
cannot find symbol variable scantest.i have that in same folder where all classes are in why wont it read it?
scanner class in which i need help fixing the above errors import java.io.BufferedReader; import java.io.FileReader; import java.io.*; public class scanner implements CompilerConstants { private char c; private BufferedReader source; public int token; private String attr = ""; private public scanner(BufferedReader buffer) { source = buffer; getChar(); } public void getChar() { c = (char)(source.read()); } public boolean lookup(String word) { boolean check = false; for(int i=0; i < RESERVEDWORD.length;i++) if(word==(RESERVEDWORD[i])) { check = true; } return check; } public Token nextToken() throws IOException { attr = ""; while(c!=EOFCHAR); { while (Character.isWhitespace(c)) { getChar(); } if (Character.isLetter(c)) { while(Character.isLetterOrDigit(c)) { attr = attr + c; getChar(); } return new Token(lookup(attr), attr); } else if (Character.isDigit(c)) { while(Character.isDigit(c)) { attr = attr + c; getChar(); } return new Token(NUMBER, attr); } else { switch (c) { case '<' : getChar(); if(c=='>') { getChar(); return new Token(NE, null); } else if (c=='=') { getChar(); return new Token(LE, null); } return new Token(LT, null); case '>' : getChar(); if(c=='<') { getChar(); return new Token(NE, null); } else if (c=='=') { getChar(); return new Token(GE, null); } return new Token(GT, null); case '=' : getChar(); return new Token(EQ, null); case '|' : getChar(); return new Token(OR, null); case '+' : getChar(); return new Token(PLUS, null); case '-' : getChar(); return new Token(MINUS, null); case '*' : getChar(); return new Token(TIMES, null); case '/' : getChar(); return new Token(DIVIDE, null); case '[' : getChar(); return new Token(LEFTSQ, null); case ']' : getChar(); return new Token(RIGHTSQ, null); case '(' : getChar(); return new Token(LEFTPAREN, null); case ')' : getChar(); return new Token(RIGHTPAREN, null); case ',' : getChar(); return new Token(COMMA, null); case EOFCHAR : getChar(); return new Token(EOF, null); } } return Token(tokenCode, attr); } } public static void main(String[] args) { BufferedReader source = new BufferedReader(new FileReader(scantest.echo)); } }
Token class
public class Token implements CompilerConstants { private int tokenCode; private String attribute; public Token(int tc, String att) { tokenCode = tc; attribute = att; } public int getToken() { return tokenCode; } public String tokenAttribute() { return attribute; } public String toString(){ String tokenString = tokenCode + " "; switch (tokenCode) { case AND: return (tokenString + "/n AND"); case IDENTIFIER: return (tokenString + "/n IDENTIFIER" + attribute); case OR: return (tokenString + "/n OR"); case NOT: return (tokenString + "/n NOT"); case ARRAY: return (tokenString + "/n ARRAY"); case BEGIN: return (tokenString + "/n BEGIN "); case BOOLEAN: return (tokenString + "/n BOOLEAN "); case DO: return (tokenString + "/n DO "); case ELSE: return (tokenString + "/n ELSE"); case END: return (tokenString + "/n END"); case FOR: return (tokenString + "/n FOR"); case FROM: return (tokenString + "/n FROM"); case IF: return (tokenString + "/n IF"); case INTEGER: return (tokenString + "/n INTEGER"); case PROCEDURE: return (tokenString + "/n PROCEDURE"); case PROGRAM: return (tokenString + "/n PROGAM"); case READ: return (tokenString + "/n READ"); case START: return (tokenString + "/n START"); case THEN: return (tokenString + "/n THEN"); case TO: return (tokenString + "/n TO"); case TRUE: return (tokenString + "/n TRUE"); case WHILE: return (tokenString + "/n WHILE"); case WRITE: return (tokenString + "/n WRITE"); case WRITELN: return (tokenString + "/n WRITELN"); case NUMBER: return (tokenString + "/n NUMBER" + attribute); case STRING: return (tokenString + "/n STRING" + attribute); case LT: return (tokenString + "/n LT"); case LE: return (tokenString + "/n LE"); case GT: return (tokenString + "/n GT"); case GE: return (tokenString + "/n GE"); case EQ: return (tokenString + "/n EQ"); case NE: return (tokenString + "/n NE"); case PLUS: return (tokenString + "/n PLUS"); case MINUS: return (tokenString + "/n MINUS"); case TIMES: return (tokenString + "/n TIMES"); case DIVIDE: return (tokenString + "/n DIVIDE"); case LEFTSQ: return (tokenString + "/n LEFTSQ"); case RIGHTSQ: return (tokenString + "/n RIGHTSQ"); case LEFTPAREN: return (tokenString + "/n LEFTPAREN"); case COLONEQUAL: return (tokenString + "/n COLONEQUAL"); case COMMA: return (tokenString + "/n COMMA"); case EOF: return (tokenString + "/n EOF"); } return tokenString; } }
CompilerConstants class
public interface CompilerConstants { public static final int AND = 1; public static final int ARRAY = 2; public static final int BEGIN = 3; public static final int BOOLEAN = 4; public static final int DO = 5; public static final int ELSE = 6; public static final int END = 7; public static final int FALSE = 8; public static final int FOR = 9; public static final int FROM = 10; public static final int IF = 11; public static final int INTEGER = 12; public static final int NOT = 13; public static final int OR = 14; public static final int PROCEDURE = 15; public static final int PROGRAM = 16; public static final int READ = 17; public static final int START = 18; public static final int THEN = 19; public static final int TO = 20; public static final int TRUE = 21; public static final int WHILE = 22; public static final int WRITE = 23; public static final int WRITELN = 24; public static final int IDENTIFIER = 30; public static final int NUMBER = 31; public static final int STRING = 32; public static final int LT = 33; public static final int LE = 34; public static final int GT = 35; public static final int GE = 36; public static final int EQ = 37; public static final int NE = 38; public static final int PLUS = 39; public static final int MINUS = 40; public static final int TIMES = 41; public static final int DIVIDE = 42; public static final int LEFTSQ = 43; public static final int RIGHTSQ = 44; public static final int LEFTPAREN = 45; public static final int RIGHTPAREN = 46; public static final int COLONEQUAL = 47; public static final int COMMA = 48; public static final int EOF = 99; public static final char EOFCHAR = (char)(-1); public static final String[] RESERVEDWORD = {"","and","array","begin","boolean", "do","else","end","false","for","from","if","integer","not","or", "procedure","program","read","start","then","to","true","while", "write","writeln"}; public static final boolean DEBUG = true; }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
import java.util.Random; /** * Write a description of class PokerHand here. * * @author David Singleton * @version 11/08/09 */ public class PokerHand {
public PokerHand() { this.arrDeck = new int[5]; // this.hand = new int[5]; // } // private ArrayList coins; public static void main(String[] args) { } public boolean haveCard(int cardValue) { // Visit each array box and compare card to the number in the box // If the card martches the array box value then return true // If the card does not match any array values in the entire array then // return false. // Use a while loop to visit each array box
if(arrDeck.length > 0) { for (int i=0; i < this.arrDeck.length; ++i) { if (this.arrDeck[i] == cardValue) { return true; } return false; } }
public void displayCards() { System.out.println("The Card Values Are: "); for(int i=0; i<=arrDeck.length; i++) { System.out.println(arrDeck[i] +"/n"); } }
public void dealCards(boolean inHand) { // syntax error "illegal start of expression" // public int randomPokerCard() Random randomGenerator = new Random(); int randomInt = 0; for(int i = 0; i { randomInt = randomGenerator.nextInt(52); randomInt ++; // boolean inHand = haveCard(4); boolean booleaninHand = this.haveCard(randomInt); if(inHand) --i; else this.arrDeck[i] = randomInt; } } }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
sweetbab wrote: PokerHand class can someone help me solve this code?
Solve what exactly? You need to explain what this is supposed to do, and what errors are occurring.
[edit]I notice that main() does not actually do anything!
The variable arrDeck is not declared anywhere.
The statement for(int i = 0; i { has obviously been pasted incorrectly, so I'm not sure what the test or termination parts should be.
I would suggest you correct these errors and repost your question with some more detail. [/edit]
modified on Sunday, November 8, 2009 7:14 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi everybody, I am doing an application using java.It requires a module to send sms to people concerned. So kindly give or help me with the algorithm or coding to send sms from computer.
Thank you.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
this is the code i have. when i run this applet, it doesn't do anything!
[quote] //Ravi Shah //Assignment 7: Java applet for a small airline company //to make reservations. //CIS 226 //11/05/09
import java.awt.Container; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*;
public class Air_Reservation extends JApplet implements ActionListener {
boolean seats[]; JButton FirstClassButton; JButton EconomyButton; JTextField BoardingPassField;
public Air_Reservation() { seats = new boolean[1]; }
public void init() { Container container = getContentPane(); container.setLayout(new FlowLayout()); FirstClassButton = new JButton("First Class"); FirstClassButton.addActionListener(this); container.add(FirstClassButton); EconomyButton = new JButton("Economy"); EconomyButton.addActionListener(this); container.add(EconomyButton); BoardingPassField = new JTextField(20); BoardingPassField.setEditable(false); container.add(BoardingPassField); }
public void actionPerformed1(ActionEvent actionEvent) { boolean FirstClass = actionEvent.getSource() == FirstClassButton; int seat = 0; if(seat == -1 ) { String ok = JOptionPane.showInputDialog(null, (new StringBuilder("Are you OK with ")).append(FirstClass ? "Economy" : "FirstClass").append(" (click OK or Cancel)").toString()); if(ok != null) { FirstClass = !FirstClass; } } if(seat > 0) { BoardingPassField.setText((new StringBuilder("Boarding Pass: Seat ")).append(seats).append(FirstClass ? " FirstClass" : " Economy").toString()); } else if(seat < -1) { BoardingPassField.setText("Next flight leaves in 3 hours"); } else { BoardingPassField.setText("All the seats have been reserved"); EconomyButton.setEnabled(false); } }
public int reserve(boolean firstClass) { int start = 1; int end = 5; boolean full = false; if(firstClass) { start = 6; end = 10; } for(int i = 1; i <= 10; i++) { if(i >= start && i <= end) { seats[i] = true; return i; } } return end;
}
public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub } } [/quote]
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
Shah Ravi wrote: this is the code i have. when i run this applet, it doesn't do anything!
What is it supposed to do?
ps Please use <pre></pre> tags around your code; there is even a "code block" button on the edit screen to make it easy for you!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
By looking at your code I can directly tell you to delete the last method (actionPerformed) and also to remove the 1 from the first (actionPerformed).But now your stuck with when you click either button you will get the same result. There are many ways to add action listeners and the way your doing it is wrong. A nice link [^]to explain it all.
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi all. I am creating an ant script for a JEE project and when compiling the webservices of that project I get the following error java.lang.IncompatibleClassChangeError: Class com.sun.tools.javadoc.ClassDocImpl does not implement the requested interface com.sun.javadoc.Type I decompiled the code of tools.jar and found that the interface is implemented but can't find out how to get rid of this error. Has anyone seen it before. I am working on oracle workshop with java 6 and I'm out of ideas about this. If anybody can help I would hold it in heig regard. Cheers Stephen
Stephen Lintott Bsc IT (RAU)
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I found this advice:
Every time I have seen this kind of error it was because I changed a class that other classes depended on, but did not recompile the dependent classes. Be sure that you completely delete all the old *.class files of your application, and recompile them against the new struts.jar file.
So I'd make sure you do a clean build and make sure you are linking to the correct jars. Is it possible you have two jdk's installed and you are getting the jars from different versions?
Panic, Chaos, Destruction. My work here is done.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thanks Nagy... The only thing is I'm not working with struts. These are webservices that allow the user to access control objects written by our company. All and all we have 11 projects ie 11 build.xml files for ears. 5 of them complile and 6 of them fail with the above error when they are run via a bash script that I wrote. I thought of it after the first post but does anyone know if weblogic replaces the tools.jar file when compiling. Maby named it something else. I'm not even sure if you are allowed to do that. Anyway. if anybody can help I would hold it in very high regard... Cheers Stephen
Stephen Lintott Bsc IT (RAU)
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi to all,this is my first post... I've built a java program which retrive some datas from a website and organize them in a JTable... nothing too complicated
The "bigger" problem was that I need to make it start at system startup (it's a desktop application for some users) I build a dll with JNI and created some functions to interact with registry, after that was easy to write on the system register and yes I managed to run the application at system startup. Actually I'm using a wrapper for my jar files called "launch4j", which simply call my jar file (I don't need to wrap or something like it... just the users are more "user-friendly" with an exe file instead of a jar (I don't need a JVM check because i'm doing it at installation time, with another tool)...
However, the exe is called but I got these errors
Problemi nella creazione della GUI: null java.lang.NumberFormatException: null at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.(Unknown Source) at gui.Home.(Home.java:52) at cittanascostauc.Main$1.run(Main.java:22) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
And if I disable the part of that integer (the problem is that is read from a file, so the problem is the file reading and not exactly the cast), so I have only the part referred to the DLL I receive this error:
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no AutoSt artChecker in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at core.AutoStartChecker.(AutoStartChecker.java:35) at gui.Home.(Home.java:72) at cittanascostauc.Main$1.run(Main.java:22) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
Actually if I manually run the exe file, everything goes fine... it's something like no dll are loaded... In fact if I disable everything about File reading and DLL Management, the GUI comes up and everything works fine (even if the user call some operations which read/write on file)
How can I resolve this problem?any suggestion?
EDIT: New discover! I've build this batch file:
cd "C:\Documents and Settings\Administrator\Desktop" MyWrapperForApp.exe
If I run this on system startup everything works... (yes that's not what I want) I've understood why this happen: it looks like that when I run my jar app at startup, the "dir" where it's run from it's not (currently is on my desktop) the desktop, but somewhere else (probably C:\WINDOWS\system32 ?Or where the jre is, more probably). So actually my jar file starts (infact I "arrive" inside my main function) and then I got some bugs... The solution could be simply changing the current working dir of my jar file, do someone know how to do this? It will be very appreciated a help
modified on Monday, November 2, 2009 9:33 PM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Your discovery is the answer. If you check the properties of the item in the start-up it should have a 'start-in' location, this needs to be changed.
Panic, Chaos, Destruction. My work here is done.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
This is only a suggestion, why not use ServiceMill[^] It will save you the time. The only thing you do is right click on the jar and install it as a windows service from there you can manipulate all the properties you want from the services executable provided by the application or from windows services.exe
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Not a bad idea, except a windows service cannot have any UI.
Panic, Chaos, Destruction. My work here is done.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Your conclusion is true if you set the interact with desktop property to false otherwise the UI of the jar will load normally
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Well the problem is that the java program is a part of a bigger program working through a website, so buying a license (and by the way I want that the user don't understand that there is an external program)... so buying a license is not a good idea if i'm going to sell this (or I have to increase the cost of the program by 80$). Also it's not very good to discard all my job about working with system register (i've worked hard to make it works)... I prefer in changing the path if possible, I'll test soon and report any bugs
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I create a socket connection that listens for commands that sends from the client. I try to printout the command while it is reading it. ... However, I can only see the printout after I stop the client sending commands. The socket will receive a long commands that each small command is seprated by '/r'.
my client code is writen in C++, which uses a socket connection to send command to a system...
since the system is not ready to test yet, I wrote a java server socket to see if the command that sends from the C++ code is correct also want to check to see if the C++ can receives any response from the server socket ....
it's stuck as the point of the read method
public class SocketSim { public static final int PORT = 2000; public static void main(String[] args) throws IOException { ServerSocket ss = new ServerSocket(PORT); Socket accept = ss.accept(); System.out.println("Server socket opened and ready on " + PORT); for (;;) try { accept = ss.accept(); processRequest(accept); } catch (Exception e) { System.err.println(e); } finally { if (null != accept) try { accept.close(); } catch (Exception e) { System.err.println("Failed socket close()"); } } } static void processRequest(Socket s) throws IOException { InputStream is = s.getInputStream(); String req=""; int i = 0; while (i != -1) { int j = is.read(); char c = (char) j; if (j != -1) req += c; if (c == '\r') { System.out.println("each request: " + req); req = ""; } } }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
Threads
public class example { public static void main(String[] args) { long interval = 10000; MyScheduler scheduler = new MyScheduler(); Timer timer = new Timer(); timer.schedule(scheduler, new Date(), interval);
} } class MyScheduler extends TimerTask { public void run() { } }
don't forget import java.util.*;
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
sorry, would you expain a bit more about the code provided??? what I have now is client server chat I'm going to upgrade it to the online auction program.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |