|
Hey,
Anyone have an example of a J2ME 2d side scroller game code i can look at?
Thanks
|
|
|
|
|
hello guys.....have you been able to find a method which could clear the screen in java?? Can we try, putting in a loop, something like
gotoxy(i,j);
where i,j are rows and columns respectively and then printing a balnk??modified on Saturday, March 13, 2010 4:37 AM
|
|
|
|
|
Do you mean in a console or swing application? If it's swing then you have total control of what is drawn to the screen. In a console app there is no concept of a window. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
yes...i wanted it on a console....im trying hard to find this out but still, u know. I have read somewhere that we can use System.exec("cls"); but that too is not working.
|
|
|
|
|
I am not sure this is possible from Java. "cls" is an internal 'MSDOS' command so can only be run from an invocation of CMD.EXE. However I do not think that this will do what you want. Take a look at Runtime.getruntime().exec() for further information.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
hello Friends
I am using java3d Library.In regarding to that I am creating a scene with Multitexture.For that I am using Combine Mode,SetCombineRGBSource function.But I am not getting the full description of SetCombineRGBSource function,specially its parameter.
Is anyone aware of all these?
Thanks & Regards
Yogesh Sikri
|
|
|
|
|
Hey all,
I'm having trouble getting an applet to use the printer. Every time, it pops a message stating "The applet has requested access to the printer. Do you want to allow this action?" I check yes to an option underneath stating to always allow access, however, it seems that there is a lack of communication going on here, because the same message pops up next time. I've read that this can be fixed by adding this line to the java policy security file (java.policy):
permission java.lang.RuntimePermission "queuePrintJob";
But that solution doesn't work well for me, because I can't have everyone that uses my applet change their security files to avoid the annoying popup. The applet is signed, however, it's print method is being called directly from javascript and so I think there may be a bit of security tightening going on there causing the problem. Is there a checkbox or a setting somewhere I can have my users set, or is there something I can do on my end?
|
|
|
|
|
The problem here is that applets run in the browser, and browsers are not allowed access to system resources without the express permission of the PC user. Otherwise their systems could be compromised by webpages changing things without their knowledge. I don't think there is any way round this issue. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
True, which is why there is a security policy file, which prevents access as the default. However, you can get around it by adding that line to the file. I was wondering if there was an easier way to change it, rather than editing that policy file by hand.
|
|
|
|
|
Klazen wrote: I was wondering if there was an easier way to change it
Not that I am aware of; and remember it would still require every user of your applet to change their own system.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Hello Klazen,
by seeing your post i am sending this Qus.
if you dont mind can you provide the code for printing the file from applet.
Please help me.............
|
|
|
|
|
> The applet is signed, however, it's print method is being called directly from javascript and so I think there may be a bit of security tightening going on there causing the problem.
You are correct. Wrap the call in a doPriviliged() method and it should work (in a trusted applet) without further intervention.
Messing with policy files is not something I would recommend even for development purposes.
|
|
|
|
|
We tried this fix and it seems to be causing further problems. Our implementation is:
try {
final Doc doc = new SimpleDoc (docBytes, javax.print.DocFlavor.BYTE_ARRAY.AUTOSENSE, null);
AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws PrintException {
DocPrintJob printerJob = selectedPrinter.getPrintService().createPrintJob();;
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
printerJob.print(doc, aset);
result.setStatus("SUCCESS");
return null;
}
});
}
catch (Exception e) {
e.printStackTrace();
result.setStatus("FAILED");
}
We're using the doPrivileged call with PrivilegedExceptionAction so that we can report the failure to the server to be reported. The problem is we are now seeing in the production logs that a small percentage of the print jobs fail with PrivilegedActionException, which we never saw before. We have not been able to reproduce this in our test environments, so in fact we don't really know whether the previous versions were failing or not - maybe we're just seeing the exceptions in the logs now, but they were always there.
|
|
|
|
|
import java.io.*;
import java.net.*;
class EchoServer
{
public static void main(String args[]) throws Exception
{
String clientstr;
String fwdstr;
ServerSocket ssock = new ServerSocket(5678);
while(true)
{
Socket conn = ssock.accept();
BufferedReader inFromClient =new BufferedReader(new InputStreamReader(conn.getInputStream()));
DataOutputStream outToClient =new DataOutputStream(conn.getOutputStream());
clientstr = inFromClient.readLine();
System.out.println("Input from the Client: "+clientstr);
fwdstr = clientstr+ '\n';
outToClient.writeBytes(fwdstr);
}
}
}
this is an echo server..i would like to know how could i make sure that multiple instances of this server is not running elsewhere on the network??? please help..
|
|
|
|
|
Please do not cross-post[^] your questions. One post is enough. Kristian Sixhoej
"You can always become better." - Tiger Woods
|
|
|
|
|
hello guys....having a little problum in printf() function in java. I want to show data from ArrayList in a tabular form but unable to find proper examples of printf() function.Lets suppose each record in ArrayList consists of following
1) name
2) address
3) balance
How do i do this??......thanx for ur help
|
|
|
|
|
You probably want to use print/println[^] to get the right results. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
for(Record r : yourArrayList)
{
printf("Name:%s\tAddress:%s\tBalance:%d\n",r.name,r.address,r.balance);
}
Note:i suppose that balance is integer so i used the "%d" format.
|
|
|
|
|
yes, but which class to import? it shows an error saying that it can not find printf() method in java.lang.String, though i have also included the java.util.*modified on Saturday, March 13, 2010 2:28 AM
modified on Saturday, March 13, 2010 2:31 AM
|
|
|
|
|
Did you read my previous reply? txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
i did....and implemented it successfully as well. thanx.......
|
|
|
|
|
My apologies, but printf() is part of PrintWriter and may be accessed through System.out .txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Please give any the reason that how it works?????
|
|
|
|
|
with the normal try/catch mechanismus. This exception should only get thrown if you allocate real hughe memory blocks ( maybe > 1 GB). If that fails your program isnt dead enough... Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
The same way you catch any exception is the short answer. However, if you have an OutOfMemory condition then chances are that nothing (including catching the exception) will be possible any longer. In many cases your entire system will stop working for a while at least. Further details can be found here[^]. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|