|
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
|
|
|
|
|
Richard MacCutchan wrote: The same way you catch any exception is the short answer
Out Of Memory is an Error, not an Exception. You need to catch either Error or Throwable for this, catching Exception won't work.
|
|
|
|
|
Well he asked how to catch it; the answer is in a catch() statement. I did not specify catch(Exception) in my answer, but left it to the questioner to check the details.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Hello friends
I am new to java3D so I installed j3d .
After that i cameto know abt jgl.
So i want to know that can I use both Libraries ?
If not then Is jgl easier than j3d to load 3d objects on web.
And one more jgl classses are quite same as j3d or totally different?
Thanks In Advance.
Regards
Yogesh
|
|
|
|
|
Hi
I am comparing possibilities for creating custom design surfaces (forms designer) for a course at university.
Example in C# WinForms: Have a Great DesignTime Experience with a Powerful DesignSurface (Extended) Class[^]
Is something like that possible in Java as well (i think so ).
Do you know any examples/tutorials/references where I can find some information about it?
If you know any examples besides Java and C# WinForms I would appreciate it if you'll let me know.
Thank you
|
|
|
|
|
Try a Google search, there are hundreds of Java tutorials on the web. The Java Tutorials[^] home page has a number to get you started. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Maybe you've misunderstood my intention of my question.
I am not looking for java programming tutorials or building simple Guis.
I am more looking for creating my own "Gui Builder" and if there a references, guidelines or tutorial for this case.
I've found GEF (Graphical Editing Framework) (http://www.eclipse.org/gef/overview.html[^]), I think this could help
|
|
|
|
|
akamper wrote: I am more looking for creating my own "Gui Builder"
Which is the same thing; and I'm pleased that you took my advice and searched for it.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
You might also want to take a look at NetBean's Gui designer (Matisse). It is open source and you can download the source code from the NetBeans site to see how it works or to extend it and add in your own features if you want.
|
|
|
|