hello
how could we uses junir related methods?
could we launch setuponce from each java test?
if in my test I launch the appli by calling setuponce, is it correct ?
I am working on a java Ant+Ivy based project that has the following directory structure:
projectRoot/src
projectRoot/classes
projectRoot/conf
projectRoot/webservices
this works perfectly well in Ant but I am looking to migrate to Gradle.
Is there a way to define a non-maven directory structure in gradle or should I be looking to mavenize?
I have written a program that creates nodes that in this class are parts of polynomials and then the two polynomials get added together to become one polynomial (list of nodes). All my code compiles so the only problem I am having is that the nodes are not inserting into the polynomial via the insert method I have in polynomial.java and when running the program it does create nodes and displays them in the 2x^2 format but when it comes to add the polynomials together it displays o as the polynomials, so if anyone can figure out whats wrong and what I can do to fix it it would be much appreciated.
Here is the code:
import java.util.Scanner;
class Polynomial{
public termNode head;
public Polynomial()
{
head = null;
}
public boolean isEmpty()
{
return (head == null);
}
public void display()
{
if (head == null)
System.out.print("0");
else
for(termNode cur = head; cur != null; cur = cur.getNext())
{
System.out.println(cur);
}
}
public void insert(termNode newNode)
{
termNode prev = null;
termNode cur = head;
while (cur!=null && (newNode.compareTo(cur)<0))
{
prev = null;
cur = cur.getNext();
}
if (prev == null)
{
newNode.setNext(head);
head = newNode;
}
else
{
newNode.setNext(cur);
prev.setNext(newNode);
}
}
public void readPolynomial(Scanner kb)
{
boolean done = false;
double coefficient;
int exponent;
termNode term;
head = null; //UNLINK ANY PREVIOUS POLYNOMIAL
System.out.println("Enter 0 and 0 to end.");
System.out.print("coefficient: ");
coefficient = kb.nextDouble();
System.out.println(coefficient);
System.out.print("exponent: ");
exponent = kb.nextInt();
System.out.println(exponent);
done = (coefficient == 0 && exponent == 0);
while(!done)
{
Polynomial poly = new Polynomial();
term = new termNode(coefficient,exponent);
System.out.println(term);
poly.insert(term);
System.out.println("Enter 0 and 0 to end.");
System.out.print("coefficient: ");
coefficient = kb.nextDouble();
System.out.println(coefficient);
System.out.print("exponent: ");
exponent = kb.nextInt();
System.out.println(exponent);
done = (coefficient==0 && exponent==0);
}
}
public static Polynomial add(Polynomial p, Polynomial q)
{
Polynomial r = new Polynomial();
double coefficient;
int exponent;
termNode first = p.head;
termNode second = q.head;
termNode sum = r.head;
termNode term;
while (first != null && second != null)
{
if (first.getExp() == second.getExp())
{
if (first.getCoeff() != 0 && second.getCoeff() != 0);
{
double addCoeff = first.getCoeff() + second.getCoeff();
term = new termNode(addCoeff,first.getExp());
sum.setNext(term);
first.getNext();
second.getNext();
}
}
else if (first.getExp() < second.getExp())
{
sum.setNext(second);
term = new termNode(second.getCoeff(),second.getExp());
sum.setNext(term);
second.getNext();
}
else
{
sum.setNext(first);
term = new termNode(first.getNext());
sum.setNext(term);
first.getNext();
}
}
while (first != null)
{
sum.setNext(first);
}
while (second != null)
{
sum.setNext(second);
}
return r;
}
}
Here is my Node class:
class termNode implements Comparable
{
private int exp;
private double coeff;
private termNode next;
public termNode(double coefficient, int exponent)
{
coeff = coefficient;
exp = exponent;
next = null;
}
public termNode(termNode inTermNode)
{
coeff = inTermNode.coeff;
exp = inTermNode.exp;
}
public void setData(double coefficient, int exponent)
{
coefficient = coeff;
exponent = exp;
}
public double getCoeff()
{
return coeff;
}
public int getExp()
{
return exp;
}
public void setNext(termNode link)
{
next = link;
}
public termNode getNext()
{
return next;
}
public String toString()
{
if (exp == 0)
{
return(coeff + " ");
}
else if (exp == 1)
{
return(coeff + "x");
}
else
{
return(coeff + "x^" + exp);
}
}
public int compareTo(Object other)
{
if(exp ==((termNode) other).exp)
return 0;
else if(exp < ((termNode) other).exp)
return -1;
else
return 1;
}
}
And here is my Test class to run the program.
import java.util.Scanner;
class PolyTest{
public static void main(String [] args)
{
Scanner kb = new Scanner(System.in);
Polynomial r;
Polynomial p = new Polynomial();
System.out.println("Enter first polynomial.");
p.readPolynomial(kb);
Polynomial q = new Polynomial();
System.out.println();
System.out.println("Enter second polynomial.");
q.readPolynomial(kb);
r = Polynomial.add(p,q);
System.out.println();
System.out.print("The sum of ");
p.display();
System.out.print(" and ");
q.display();
System.out.print(" is ");
r.display();
}
}
Hi all,
I have been using JBoss Seam now for over a year and still haven't seen much acceptance here in the US. My metrics are, the number of jobs that indicate JBoss Seam and number of people talking about JBoss Seam (Java groups / JBoss Seam groups, etc.).
Is JBoss Seam more popular outside the US?
Walter
<c:forEach items="${myParams.items}" var="currentItem" varStatus="stat">
<c:set var="myVar" value="<c:out var="myVar" />" />
</c:forEach>
I want to concatenate the values of currentItem.myVar and output it at the end of the loop, problem is I can't figure out how to do this...
(Preferably not using Java)
I'm wondering if anyone is aware of a web-based dos emulator that would allow running dos games through a browser window? Perhaps written in Flash, Silverlight, AJAX, or Java?
I am looking for code that will add favorites / MRU type behavior to a JComboBox.
I could code this myself, but it sure seems like someone else has probably already done it.
I found the following (which looks exactly like what I want, but the source code is nowhere near complete): http://java.sys-con.com/node/36658
Any suggestions? I need to keep this relatively light, so I'd prefer to not use a component that's part of a monolithic widget library, and open source is preferred.
I have a java.io.Reader as the return type of my method. But i have Object type of an instance which i get from Database. So how can I convert this to Reader type and return?
need help
thanks.
We're getting this random warning from JBoss.. any idea why?
It happens at random times when there are no active threads. Everything works when any processing resumes.
13:49:31,764 WARN [JBossManagedConnectionPool] [ ] Unable to fill pool
org.jboss.resource.JBossResourceException: Could not create connection; - nested
throwable: (java.sql.SQLException: Listener ref
used the connection with the following error:
ORA-12516, TNS:listener could not find available handler with matching protocol stack
The Connection descriptor used by the client was:
//localhost:1521/orcl
In the project I am working I have deployed a SOAP server using Deployment Descriptors (WSDD) files. To do that a webserver (e.g tomcat, jetty) is started and then the following command is executed:
java -cp %AXISCLASSPATH% org.apache.axis.client.AdminClient deploy.wsdd
What I need is to skip the above command to avoid a call to the Axis AdminClient. Is it possible to deploy my webservice as war file?
Note: A solution with JWS can't be used due to its limitations.
Situation: jax-ws web service on Weblogic appserver; wsdl first development, jaxb customizations in external binding file.
I would like to get a handle to the actual jaxb context that will process the incoming soap xml message, before it has been unmarshalled into java objects.
Then I would like to get the unmarshaller of this jaxb context - the one that actually will be used during the unmarshalling. And then setup some properties of this unmarshaller (e.g. listener and idresolver).
I'm creating a JAX-WS type webservice, with operations that return an object WebServiceReply. The class WebServiceReply itself contains a field of type Object. The individual operations would populate that field with a few different data-types, depending on the operation.
Publishing the WSDL (I'm using Netbeans 6.7), and getting a ASP.NET application to retrieve and parse the WSDL was fine, but when I tried to call an operation, I would receive the following exception:
javax.xml.ws.WebServiceException: javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: class [LDataObject.Patient; nor any of its super class is known to this context.]
How do I mark the annotations in the DataObject.Patient class, as well as the WebServiceReply class to get it to work? I haven't been able to fine a definitive resource on marshalling based upon annotations within the target classes either, so it would be great if anybody could point me to that too.
WebServiceReply.java
@XmlRootElement(name="WebServiceReply")
public class WebServiceReply {
private Object returnedObject;
private String returnedType;
private String message;
private String errorMessage;
.......... // Getters and setters follow
}
DataObject.Patient.java
@XmlRootElement(name="Patient")
public class Patient {
private int uid;
private Date versionDateTime;
private String name;
private String identityNumber;
private List<Address> addressList;
private List<ContactNumber> contactNumberList;
private List<Appointment> appointmentList;
private List<Case> caseList;
}
Solution
(Thanks to Gregory Mostizky for his answer)
I edited the WebServiceReply class so that all the possible return objects extend from a new class ReturnValueBase, and added the annotations using @XmlSeeAlso to ReturnValueBase. JAXB worked properly after that!
Nonetheless, I'm still learning about JAXB marshalling in JAX-WS, so it would be great if anyone can still post any tutorial on this.
Gregory: you might want to add-on to your answer that the return objects need to sub-class from ReturnValueBase. Thanks a lot for your help! I had been going bonkers over this problem for so long!
I'm trying to save a file to a Sharepoint server using JAX-WS. The web service call is reporting a success, but the file doesn't show up.
I used this command (from a WinXP) to generate the Java code to make the JAX-WS call:
wsimport -keep -extension -Xnocompile http://hostname/sites/teamname/_vti_bin/Copy.asmx?WSDL
I get a handle on the web service which I called port using the following:
CopySoap port = null;
if (userName != null && password != null) {
Copy service = new Copy();
port = service.getCopySoap();
((BindingProvider) port).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, userName);
((BindingProvider) port).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
} else {
throw new Exception("Holy Frijolé! Null userName and/or password!");
}
I called the web service using the following:
port.copyIntoItems(sourceUrl, destUrlCollection, fields ,
"Contents of the file".getBytes(),
copyIntoItemsResult, copyResultCollection)
The sourceUrl and the only url in destUrlCollection equals "hostname/sites/teamname/Tech Docs/Sub Folder".
The FieldInformationCollection object named fields contains only one FieldInformation.
The FieldInformation object has "HelloWorld.txt" as the value for displayName, internalName and value.
The type property is set to FieldType.FILE. The id property is set to (java.util.UUID.randomUUID()).toString().
The call to copyIntoItems returns successfuly; copyIntoItemsResult contains a value of 0 and the only CopyResult object
set in copyResultCollection has an error code of "SUCCESS" with a null error message.
When I look into the "Tech Docs" library on Sharepoint, in the "Sub Folder" there's no file there.
Why wouldn't it tell me what I did wrong? Did I just miss a step?
Update (Feb 26th, 2011)
I've changed my FieldInformation object's displayName and internalName properties to be "Title" as suggested. Still no joy, but a step in the right direction.
After playing around with the urls for a bit, I got these results:
With both the sourceUrl and the only destination URL equivalent, with no protocol, I get the SUCCESS response but no actual document appears in the document library.
With both of the URLs equivalent but with an "http://" protocol specified, I get an UNKNOWN error with "Object reference not set to an instance of an object." as the message.
With the source URL an empty string or null, I get an UNKNOWN error with " Value does not fall within the expected range." as the error message.
hello all.
I have an array:
int test[]={10212,10202,11000,11000,11010};
I want to split the inetger values to individual digits and place them in a new array as individual elements such that my array now is:
int test2[]={1,0,2,1,2,1,0,2,0,2,1,1,0,0,0,1,1,0,0,0,1,1,0,1,0};
How would i go about doing that? I'm doing this in java.
Thank you.
I am currently using Selenium 2.0a2 in Java to access the Internet using an HtmlUnitDriver instance. The problem I am facing is that, when I attempt to access slow websites, the request times out. How can I increase the time that WebDriver waits before throwing a timeout exception?
This is my problem, I have to use a big SP, and there is no time to rewrite in java.
So I'm using Hibernate criteria and I don't know if i can call it. Thanks to all.
Has anyone been able to get Oracle Forms running JInitator to loan in Internet Explorer 8 yet? I have tried removing all add-ons, various version of Java, add the domain to the trusted sites using wildcards, and using compatibility mode to no avail. I am looking to get our Oracle guys to kick there Internet Explorer 6 habit. This is related to Oracle E-Business.
I´m developing a Java solution for manage an iTunes Library (ITL file). The ITL format is a propietary one.
I'm looking for an implementation or a documentation about ITL format but Google can't find anything useful.
Does anyone have experience about that? Where to find more information?
Thanks in advance.
HI,
I need to know how to set class path for the client tag
under web service of build.xml in java.
I have to add the log4j.properties file to the client jar.
Thanks
Abhi
hi,
I'm trying to access owl file using jsp.I've successfully load the owl file and quering that using SPARQL.But still I couldn't success with JSP.
I'm always getting error "java.lang.ClassNotFoundException: com.hp.hpl.jena.util.FileManager
"
help me!
Thank in advance!
I have a class Client.java in two different jars jar1 & jar2
Now at run time i want to decide which Client.class loaded like
if (country==india){
// load Client class of jar1
) else{
load client class from jar2
}
can i do that...
Hi,
there is a poker-system in java, that uses Collections.shuffle() on all available cards before the cards are dealt.
So a collection of 52 cards 2-9, J, Q, K, A in 4 types.
After that we Collections.shuffle().
The problem is, that it seems (until now we didn't have big statistic, it's possible that we only see a lot of statistic inferences), that the algorithm is VERY unclearly.
So, is Collections.shuffle() okay for a poker algorithm?
Hi!
Is it possible to set 'clipping bounds' in JOGL? Like in Java/Swing i would like to set clipping bounds and all drawing/rendering outside those bounds would be ignored.