Help with Java Threads
Hello,
Can anyone help with what I'm trying to do:
I would like to create a thread such as:
Database connection successful....
where the '...' keep moving up. So as long as there is a database connection the '...'s should keep moving like so:
...... then back to:
Does that make sense?
Thanks
am328
What you want to do if really very simple...
Why don't you first write a simple loop that generates your '.'s. Once you get that working, wrap the loop inside a thread that checks for a database connection.
Similar Messages
-
Need help with java thread program
Hi
I have an applet which does some painting etc, i need to write a thread which runs in background, and if there is no user activity for 30 min will refresh the screen.
I have one good thing that all user options go from one program so i know when user does some thing.
How do i write this thread program?
1. I need this program to start counter as soon as some activity is done by user
2. When user does some thing stop this thread
3. when user completes his action restart the thread with 30 min timer.
4. when there is no activity for 30 min refresh the screen
Any help will be really good
AshishNot sure what the problem is. Your pseudo code looks good to me.
The only suggestion I would make is that your use a Timer so you don't have to worry about creating your own Thread. You schedule a Timer to fire in 30 minutes. Everytime you have activiity you cancel the timer and reschedule it. -
PI File adapter has a processing option u2018Empty-Message Handlingu2019 to ignore or Write Empty Files. In case there is no data created after mapping on target side then this option determines whether to write an empty file or not. But there is a catch to this option when it comes to using it with File Content Conversion which is described in SAP Note u2018821267u2019. It states following:
I configure the receiver channel with File content conversion mode and I set the 'Empty Message Handling' option to ignore. Input payload to the receiver channel is generated out of mapping and it does not have any record sets. However, this payload has a root element. Why does file receiver create empty output file with zero byte size in the target directory? Example of such a payload generated from mapping is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<ns1:test xmlns:ns1="http://abcd.com/ab"></ns1:test>
solution :
If the message payload is empty (i.e., zero bytes in size), then File adapter's empty message handling feature does NOT write files into the target directory. On the other hand, if the payload is a valid XML document (as shown in example) that is generated from mapping with just a root element in it, the File Adapter does not treat it as an empty message and accordingly it writes to the target directory. To achieve your objective of not writing files (that have just a single root element) into the target directory, following could be done:
Using a Java or ABAP Mapping in order to restrict the creation of node itself during mapping. (This cannot be achieved via Message Mapping)
Using standard adapter modules to do content conversion first and then write file.
can someone help with java mapping that can be used in this case?Hi,
You have not mentioned the version of PI you are working in. In case you are working with PI 7.1 or above then here is the java mapping code you need to add after message mapping in the same interface mapping
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
public class RemoveRootNode extends AbstractTransformation{
public void execute(InputStream in, OutputStream out)
throws StreamTransformationException {
// TODO Auto-generated method stub
try
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
DocumentBuilder builderel=factory.newDocumentBuilder();
/*input document in form of XML*/
Document docIn=builderel.parse(in);
/*document after parsing*/
Document docOut=builderel.newDocument();
TransformerFactory tf=TransformerFactory.newInstance();
Transformer transform=tf.newTransformer();
if(docIn.getDocumentElement().hasChildNodes())
docOut.appendChild(docOut.importNode(docIn.getDocumentElement(),true));
transform.transform(new DOMSource(docOut), new StreamResult(out));
else
out.write(null);
catch(Exception e)
public void setParameter(Map arg0) {
// TODO Auto-generated method stub
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
RemoveRootNode genFormat=new RemoveRootNode();
FileInputStream in=new FileInputStream("C:\\apps\\sdn\\rootNode.xml");
FileOutputStream out=new FileOutputStream("C:\\apps\\sdn\\rootNode1.xml");
genFormat.execute(in,out);
catch(Exception e)
e.printStackTrace();
public void transform(TransformationInput arg0, TransformationOutput arg1)
throws StreamTransformationException {
// TODO Auto-generated method stub
this.execute(arg0.getInputPayload().getInputStream(), arg1.getOutputPayload().getOutputStream());
In case you are working in PI 7.0 you can use this code
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
public class RemoveRootNode implements StreamTransformation{
public void execute(InputStream in, OutputStream out)
throws StreamTransformationException {
// TODO Auto-generated method stub
try
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
DocumentBuilder builderel=factory.newDocumentBuilder();
/*input document in form of XML*/
Document docIn=builderel.parse(in);
/*document after parsing*/
Document docOut=builderel.newDocument();
TransformerFactory tf=TransformerFactory.newInstance();
Transformer transform=tf.newTransformer();
if(docIn.getDocumentElement().hasChildNodes())
docOut.appendChild(docOut.importNode(docIn.getDocumentElement(),true));
transform.transform(new DOMSource(docOut), new StreamResult(out));
else
out.write(null);
catch(Exception e)
public void setParameter(Map arg0) {
// TODO Auto-generated method stub
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
RemoveRootNode genFormat=new RemoveRootNode();
FileInputStream in=new FileInputStream("C:\\apps\\sdn\\rootNode.xml");
FileOutputStream out=new FileOutputStream("C:\\apps\\sdn\\rootNode1.xml");
genFormat.execute(in,out);
catch(Exception e)
e.printStackTrace();
The code for PI 7.0 should also work for PI 7.1 provided you use the right jar files for compilation, but vice-versa is not true.
Could you please let us know if this code was useful to you or not?
Regards
Anupam
Edited by: anupamsap on Dec 15, 2011 9:43 AM -
Where should one ask for help with a thread ???
Having posted a link to this thread because the op needed someone to check a site in Panther.... and because not so long ago I read here that this was the place to ask for such help.....
I now find the my request has been removed... musta offended the tou of course.
Sooo - how should a person try to get help with a thread in future? - we ain't all l4's and have a lounge to play in.Interesting question. This forum was available for this type of request at certain points in Discussions' history, and it has often been recommended that users post issues like yours here.
Technically, as per the red print at the top of this forum, it is inappropriate to use this forum for that purpose. In the case you cite, I'd recommend putting a new topic in to the Safari forum with a specific request for the help that is required in the Subject line. If you do it that way, you will most likely reach more users who will be able to help you.
Good luck. -
Hi everybody,
I have a simple Java application that has a JFrame containing a TextField displaying some text inside it. I am using the NetBeans IDE. I am trying to Enable Java Web start for this application. The steps I have taken upto now are:
1. Right click on Project, Java Web Start -> Enable Java Web Start. This created the jnlp file.
2. In the Resources section, I added the jar file for swing. ( I am not sure if I have to add the path for jnlp.jar etc, or are these found automatically?)
3. Right click on Project, Java Web Start -> Deploy with Java Web Start. This launches the browser with the Click me link, but on clicking this link, I get the following error.
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Wrapper cannot find servlet class jnlp.sample.servlet.JnlpDownloadServlet or a class it depends on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:534)
root cause
java.lang.ClassNotFoundException: jnlp.sample.servlet.JnlpDownloadServlet
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1332)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1181)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:534)I have all the jnlp files in my jdk directory, and I am not sure why it can't find it. Is there something I am missing?
Thanks
GeorgeI am not sure what it has to do with servlets, I just followed a tutorial on using Netbeans with Java Web Start, and did only the steps as mentioned in my first post. And ended up with the error.
Anyways, I added the jnlp jar files(jnlp.jar, jnlp-servlet.jar, jardiff.jar) in the WEB-INF/lib directory. And it seems to deploying it now. I can get my application to load on clicking on the "Click me" link. But the controls on my application don't seem to be working.
Also, when I try to Right click on my project -> Java Web Start -> Run with Java Web Start, I get the following error message,
javaws-run: C:\Documents and Settings\Lux\Visualization\nbproject\build-jaws-impl.xml:36: Execute failed: java.io.IOException: CreateProcess: C:\j2sdk1.4.2_13\bin\javaws "file:///C:/Documents and Settings/Lux/Visualization/Visualization.jnlp" error=2
BUILD FAILED (total time: 0 seconds)
Any help appreciated.
Thanks.
George -
New @ RMI need help with java.rmi.UnmarshalException: error unmarshalling
Hi @ all out there,
I'm new with Java RMI and have to write a EventSystem for an college project where clients can subscribe to a topic and get notified when someone publishes a message to the subscribed topic.
At server-side I have a class called EventSystem that provides methods for subscribing and unsubscribing from topics, and also for posting messages (for publishers).
To subscribe i thought that the client must specify the topic and also itself ( means that a client calls in this way: obj.subscribe("mytopic", this).
The EventSystem handles a list of all clients, and whenever a new message is posted it goes trough all clients and invokes the handleMessage(String msg) method that all Clients have to provide.
On my local machine without RMi this concept works just great.
I now tried to get it working using RMI , but I get the following Exception when starting the client (the server starts fine) :
Looking up for rmiregistry at 138.232.248.22:1099
Subscriber exception:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.io.InvalidClassException: SubscriberImpl; SubscriberImpl; class invalid for deserialization
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:336)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
at $Proxy0.subscribe(Unknown Source)
at SubscriberImpl.main(SubscriberImpl.java:48)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.io.InvalidClassException: SubscriberImpl; SubscriberImpl; class invalid for deserialization
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:293)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.io.InvalidClassException: SubscriberImpl; SubscriberImpl; class invalid for deserialization
at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:713)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1733)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:306)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:290)
... 9 more
Caused by: java.io.InvalidClassException: SubscriberImpl; class invalid for deserialization
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:587)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
... 13 moreI googled now for 2 hours but can't resolve the problem alone. As far as I can understand I have to serialize Objects that I want to send to the server, right?
So how can i do this? I've never used serialization till now.
any ideas how to solve this problem?
greets from italy and sorry for my very weak english
bd_italyA class has been modified after deployment. Stop the Registry, clean, recompile, and redeploy.
-
I'm reading book "JAVA THREAD" published by OREILLY.
And on fifth chapter, it gives an example.
one Thread's two method:
private boolean done = false;
public void run()
while(!done)
foo();
public void setDone()
done = true;
it says, the run method will be compiled as machine code:
Begin method run
load register r1 with memory location 0xff12345
Label L1:
Test if register r1 == 1
If true branch to L2
Call method foo
Branch to L1
Label L2:
End method run
setDone method will be compiled like:
Begin method setDone
Store 1 into memory location 0xff12345
End method setDone
And it says " because Run method will never reload 0xff12345 to register r1(in while loop), so setDone method will never lead to run stop.
I'm so puzzled with this. I have test this code on windows platform, run method can stop after another Thread call setDone method !.
but I think "JAVA THREAD" should have error on this, so why ?If the book says it will happen like that, then the book is wrong.
I think what they meant--and what would be correct to say--is that that is an example of what could happen if you don't synchronize all access to the run variable.
The point is this: Threads can have local copies of variables, that are separate from other threads' local copies and separate from the "master" copy. The spec doesn't define where those local copies live--the implementation can put them anywhere it wants--but the most natural and sensible thing would be to store the local copies in CPU registers, rather than in main mem.
The example the book gave shows what might happen if that VM stores threads' local copies in registers. There's no guarantee that the problem they described will happen, but it could, so you have to guard against it.
You guard against it by declaring that shared variable volatile, which requires that the threads use the master copy rather than their local copies, or by synchronizing every access to that thread. Syncing requires reading from the master copy on entering the sync block (or on first access) and writing out to the master copy upon leaving the sync block. -
Help with JAVA StringObject - & assign user input; StringMethod
Hi Everyone! I need help with this Java Program, I need to write a program, single class, & file. That will prompt the user to enter a word. The output will be separted by hypens and do this until the user enters exit. I think this is done by using a string variable. Then use the length of the word to setup a loop to print each letter out with hypens. (example c-a-t)
1. I think I should store the word like this: Word.Method(). Not sure of this the API was confusing for me because I wasn't sure of what to do.
2. A string method to find out how many letters are in the user's word in order to setup a loop to print each letter out. I think I can use a While loop to accomplish this?
3. A string method to access each letter in a string object individually in order to print individual letters to the screen with those hypens. This is really confusing for me? Can this be accomplished in the While loop? or do I declare variables in the main method.
Any examples you can refer me to would be greatly appreciated. ThanksGetting user input:
This may look strange to a newbie but there's nothing much you can do since you wanted a single class file:import java.io.*
public class InputTest {
public static void main(String[] args) {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Hi! Please type a word and press enter.");
String lineReadFromUser = in.readLine();
System.out.println("You typed " + lineReadFromUser);
}You can get the lenght of a String using the length() method. Example: int len = "Foobar".length();
You can get the individual characters of a String with the charAt() method. Example: char firstCharOfString = string.charAt(0);
(remember that the argument must be from 0 to length-1)
You can access the documentation of all classes, including java.lang.String, at http://java.sun.com/j2se/1.3/docs/api/index.html You can also download the docs. -
I need some help with some Java assignments. I'm new to it, and I am having some problems.
People will help you - if you help them first by stating your problem. If it was a generic question wanting to know wether anyone will help you at all - the answer is yes, they would - you have to put your work in first however.
Ironluca -
Hi I got this error and i don't know what it means or how to fix it
if you understand it please help
Bad installation. Error invoking java vm(execv)
C:\program Files\java\ire1.5.0_10\bin\javaw.exe
I got this error when i went to add and remove programs in winXP
and highlighted a program called Goban3 and clicked on change\remove
http://www.gokgs.com/
goban3 is sign on link to KGS
if you check the site KGS you can see some java related items that have to be done i use this sights for years without problems
but now im having problems with java
thanks for serious reply
Message was edited by: r
revestThat looks alot like this.
-
Hello Everybody
I Want To Make an Alarm Application With Java Like
The User Enters Alarm Time as 3.15.4 AM or something like that
which class shall i use?
if there's any demos that would be great.
Thank YouAnother Question
In The following Code Sir I Want The User to input The Time In The Format h/m/s/am.pm
And After That Specific Time Passes an action happens
How to Do that?
import java.awt.*;
import javax.swing.*;
import java.text.DateFormat;
import java.util.Date;
public class Alarm extends Thread {
public static void main(String[] args) {
final JLabel label=new JLabel();
JButton button=new JButton("Set Alarm");
JTextArea tarea=new JTextArea("Enter Task Here",4,21);
JScrollPane scroll=new JScrollPane(tarea);
JTextField text1=new JTextField("hh",2);
JTextField text2=new JTextField("mm",2);
JTextField text3=new JTextField("ss",2);
JTextField text4=new JTextField("AM/PM",4);
text1.setToolTipText("Hours From 1 To 12");
text2.setToolTipText("Minutes From 0 To 60");
text3.setToolTipText("Seconds From 0 To 60");
JFrame frame=new JFrame("JAlarm");
frame.setSize(270,180);
JPanel panel1=new JPanel();
panel1.add(label);
panel1.add(scroll);
Thread t = new Thread() {
public void run() {
for(;;){
Date now = new Date();
label.setText(DateFormat.getTimeInstance().format(now));
t.start();
JPanel panel2=new JPanel();
panel2.add(button);
panel2.add(text1);
panel2.add(text2);
panel2.add(text3);
panel2.add(text4);
frame.setLayout(new BorderLayout());
frame.add(panel1,BorderLayout.NORTH);
frame.add(panel2,BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
} -
Help with java digital signing code
hello people.
can anybody help me?
i have find a java code to resolve my problem with sending pay in soap envelope with digital signature and attached certificate. i compiled it with jdk jdk1.6.0_37. and it works.
i need it to work in built-in jvm in oracle 9i. in oracle 9i jvm release is 1.3.1. Java code does not work there. there is an error
class import com.sun.org.apache.xerces.internal.impl.dv.util.Base64 not found in import.
i did not find this class in network.
can anybody help with rewriting it for jvm 1.3.1?
thanks in advance.
code below:
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
import java.io.*;
import java.security.Key;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.cert.Certificate;
public class Sign {
public static void main(String[] args) throws Exception {
// TODO code application logic here
BufferedReader reader = new BufferedReader(new FileReader("c:\\cert.p12"));
StringBuilder fullText = new StringBuilder();
String line = reader.readLine();
while (line != null) {
fullText.append(line);
line = reader.readLine();
KeyStore p12 = KeyStore.getInstance("pkcs12");
p12.load(new FileInputStream("c:\\cert.p12"), "Hfrtnf$5".toCharArray());
//????????? ????????? ????, ??? ????? ????? ???????????? alias ? ??????
//Key key = p12.getKey("my kkb key", "ryba-mech".toCharArray());
Key key = (Key) p12.getKey("my kkb key", "Hfrtnf$5".toCharArray());
Certificate userCert = (Certificate) p12.getCertificate("my kkb key");
String base64Cert = new String(Base64.encode(userCert.getEncoded()));
//signing
Signature signer = Signature.getInstance("SHA1withRSA");
signer.initSign((PrivateKey) key);
signer.update(fullText.toString().getBytes());
byte[] digitalSignature = signer.sign();
String base64sign = new String(Base64.encode(digitalSignature));
String base64Xml = new String(Base64.encode(fullText.toString().getBytes()));
System.out.println("<certificate>" + base64Cert+"</certificate>");
System.out.println("<xmlBody>" + base64Xml+"</xmlBody>");
System.out.println("<signature>" + base64sign+"</signature>");
Edited by: user13622283 on 22.01.2013 22:08My first search is to see if there is an Apache commons project that provides it. Lo and behold:
http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Base64.html
commons-codec. -
Help with Java Printing-Custom paper sizes
Hi,
I'm trying to print documents with custom paper sizes out of java.
I can print fine when I don't try to set the MediaSize to a custom size or when I use already named constants like: "MediaSizeName.JIS_B4"
The error message I get is this:
java.lang.ClassCastException
at javax.print.attribute.AttributeSetUtilities.verifyAttributeValue(Unknown Source)
at javax.print.attribute.HashAttributeSet.add(Unknown Source)
at hello.Printy.printDocument(Printy.java:103)
at hello.Printy.main(Printy.java:135)
The offending line(103) looks like this:
pras.add(new MediaSize(1,10,MediaSize.INCH ));The function that its from looks like this:
public void printDocument()
try
System.out.println("input file name is");
System.out.println(inputFileName);
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras);
PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
PrintService printPrintService = null;
// didn't work pras.add(new MediaSize(1,10,MediaSize.INCH) );
PrintService service = ServiceUI.printDialog(null, 200, 200,printService, defaultService, flavor, pras);
if (service != null)
System.out.println("There is a service aunty-may!!");
DocPrintJob job = service.createPrintJob();
FileInputStream fis = new FileInputStream(getInputFileName());
DocAttributeSet das = new HashDocAttributeSet();
//pras.add(new MediaSize((float)3.25, (float)4.75, Size2DSyntax.INCH ) );
// - works
//pras.add(MediaSizeName.JIS_B4);
pras.add(new MediaSize(1,10,MediaSize.INCH ));
//pras.add(new MediaSize(1,10,MediaSize.INCH) );
System.out.println("Doc has been set to custom size");
Doc doc = new SimpleDoc(fis, flavor, null);
job.print(doc, pras);
System.out.println("any doc for you?");
catch (Exception e)
e.printStackTrace();
}Any help with this would be greatly appreciated. I'm new to java but I've programmed a bunch in c++.Hmm ... no real help, but I found this note in the API:
MediaSize is not yet used to specify media. Its current role is as a mapping for named
media (see MediaSizeName). Clients can use the mapping method
MediaSize.getMediaSizeForName(MediaSizeName) to find the physical dimensions of
the MediaSizeName instances enumerated in this API. This is useful for clients which
need this information to format & paginate printing. -
Help with java coding involving stacks and queues.
I was wondering if anyone can help with tips on what to fill in for the coding.
My project is to creating a word processor by the process of 2 stacks. The methods are given, but I'm not really sure what goes in them. So I was wonder if anyone can answer this for me, or give tips that would be great thanks.
Example Code, similar to what were suppose to do, but instead it's CHARACTER stacks rather than String.
[http://www.cs.jhu.edu/~jason/226/hw3/source/EditableString.java]/** Stack of Characters to the left of the cursor; the ones
* near the top of the stack are closest to the cursor.
private Stack left;
/** Stack of Characters to the right of the cursor; the ones
* near the top of the stack are closest to the cursor.
private Stack right;Do you know how a stack works?
No - Google it
Yes - Continue on with this post
/** Another constructor.
* @param left The text to the left of the cursor.
* @param right The text to the right of the cursor.
public EditableString(String left, String right) {
// fill this in
}Do you know how to read?
No - How did you answer this question then?
Yes - Then why can't you read the comments above each method. Is it really that hard to understand?
Mel -
Hi,
I tried integrating java code with java embedding acitivity, but in em it is failing. Can anybody know how to convert the below java code to a webservice, so that I can pass the input paramaters directly to that webservice. I tried of converting java code to webservice in jdeveloper, but because of static void main it is not converting. Can somebody help me in this issue.
this is the original executable java code.
package com.holx.api.test;
import java.util.HashMap;
import com.agile.api.APIException;
import com.agile.api.AgileSessionFactory;
import com.agile.api.IAdmin;
import com.agile.api.IAgileClass;
import com.agile.api.IAgileList;
import com.agile.api.IAgileSession;
import com.agile.api.IAutoNumber;
import com.agile.api.IDataObject;
import com.agile.api.INode;
import com.agile.api.IProperty;
import com.agile.api.IServiceRequest;
import com.agile.api.PropertyConstants;
import com.agile.api.ServiceRequestConstants;
import com.agile.px.ActionResult;
import java.net.URL;
public class TestAgileAPI {
// @Override
// public ActionResult doAction(IAgileSession arg0, INode arg1,
// IDataObject arg2) {
// TODO Auto-generated method stub
// return null;
* @param args
public static void main(String[] args) {
IAgileSession m_session = null;
IAdmin admin = null;
IAgileClass cls = null;
String sr="PR-KB00028";
String userName="*******";
String password="*******";
String URL="*********";
try {
HashMap params = new HashMap();
params.put(AgileSessionFactory.USERNAME, userName);
params.put(AgileSessionFactory.PASSWORD, password);
AgileSessionFactory instance = AgileSessionFactory.getInstance(URL);
m_session = instance.createSession(params);
admin = m_session.getAdminInstance();
cls = admin.getAgileClass( "ProblemReport" );
IServiceRequest psr = (IServiceRequest)m_session.createObject( "ProblemReport", sr);
psr.setValue(ServiceRequestConstants.ATT_COVER_PAGE_DESCRIPTION, "KB-Test-20121400");
} catch (APIException e) {
e.printStackTrace();
} finally {
m_session.close();
Can somebody help me in converting this code into a webservice which accepts String SR as input from soa.
Thanks,Hi Francois,
I never tried to use a webservice in the value help wizzard, so I don't know if it works or not.
But for your problem you can build your own value help to avoid the problem.
You told us that the webservice works in the storyboard. The value help wizard "only" creates a popup iView in your model and assigns the output field of the popup to an input field in a form.
Maybe as a solution you can insert a popup to the model by yourself. Assign the output field of your popup to the input field for which you want to have the value help. Inside the popup iView you can use your custom built webservice.
I know that this is a little bit circuitous, but I think it will work.
Regards
Christophe
Maybe you are looking for
-
User with Farm Administrator rights, but NOT in Farm Administrators Group
I have an account that we recently discovered has Farm Administrator rights and was used to access Central Admin and cause some harm. When I use the "Check Permissions" on the Central Admin site, it says that account has Full Control via the Farm Ad
-
Error when execute a planning function on selected line
Hello together, we are using SAP BusinessObjects Analysis 1.4 SP9 (1.4.9.3241, Office 2013) and SAP BW 7.3 SP 11 (SAPKW73011). When executing a planning function on an selected line in the crosstab, the following error appears: The VBA Coding used i
-
Can any one have the oracle AIA certification dumps
Hi All, can any one have the Oracle AIA certification dumps please provide. Thanks, Siva
-
Extract BR's from calc manager database
Does any one have a SQL code to extract the Business rules from calc manager database in 11.1.1.3? I need this for Backup/Restore purpose.
-
Adding an iPod video to my computer that has iTunes + iPod shuffle on it
Recently purchased an iPod (with video) and would like to add it to the iTunes that was loaded with an iPod shuffle software on my computer. Can the iTunes support two different iPod devices? If so, how do I do this without losing or deleting the iPo