|
Thanks i fixed my errors. Do you know how it would be a good way to start a parser class that will work with my code?
This is what i have so far
public class Parser implements Scanner {
public Parser() {
}
public int match(expectedToken)
{
if(Token = expectedToken)
{
nextToken()
}
else if(Token != expectedToken)
{
}
break;
}
public static void type() throws IOException
{
debugStart(type);
simpleType();
if(Token, tokenCode==ARRAY)
{
match(ARRAY);
match (LEFTSQ);
match (RIGHTSQ);
match(NUMBER);
}
debugEnd(type);
}
}
modified on Tuesday, November 10, 2009 3:58 PM
|
|
|
|
|
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<string> 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
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
Implementing this should be easier Youtube[^]. Before you ask how to send an email look in this forum you will find the answer.
|
|
|
|
|
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]
|
|
|
|
|
Programmers are really amazing!
|
|
|
|
|
I think you are in the wrong place
|
|
|
|
|
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!
|
|
|
|
|
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.
|
|
|
|
|
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)
|
|
|
|
|
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.
|
|
|
|
|
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)
|
|
|
|
|
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.<init>(Unknown Source)
at gui.Home.<init>(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.<clinit>(AutoStartChecker.java:35)
at gui.Home.<init>(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
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
Not a bad idea, except a windows service cannot have any UI.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Your conclusion is true if you set the interact with desktop property to false otherwise the UI of the jar will load normally
|
|
|
|
|
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
|
|
|
|
|
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 = "";
}
}
}
|
|
|
|
|
Check out this link[^] It explains how to use c++ and Java as client/server
|
|
|
|
|
|
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.*;
|
|
|
|
|
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.
|
|
|
|
|
you said you want to add an item every x minutes to auction so change 10000 to the time you want. Now in the run method here you will write the code for the auctioning process and broadcasting the message. Note that the code will be used in the server code you wrote
|
|
|
|