|
i'm trying to read an xml file in java webservice,but the problem is even though the path is given it always searches the
"c:\programfiles\glassfish2\domains\domain1\config"
how can i give the path for the xml file in the project folder .
|
|
|
|
|
I want to know the restrictions imposed by a java applet on general programming with java. Basically I want to understand things we can do and things we cannot do...you know, where I might hit the silver lining?
PS: I am not so proficient in java technologies
|
|
|
|
|
This is the 'executive summary'
From memory and without bothering to search, a java applet cannot [should not?] go outside of the JVM except to 'phone home'. There is or should be no local IO.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
There is a java applet capable of reading the mac address. How do you think a browser application would be able to achieve this?
|
|
|
|
|
Getting your applet signed (such as by Verisign) can increase the things you are allowed to do by giving you a little more access to things outside of the 'sandbox'. Getting your applet signed does cost money...
|
|
|
|
|
Hello All,
I am using rxtxSerial library (import gnu.io.*; ) for my bridge application. Th example provided in the library's web site with nulltest.java employs only one serial port. It is powerful since it is threaded and detects incomming/outgoing streams.
However, I would like to bridge between servers so multiple ports will be employed. Do you heave any suggestion how to obtain it. The null test code is presented as follows.
import java.io.*;
import java.util.*;
import gnu.io.*;
public class nulltest implements Runnable, SerialPortEventListener {
static CommPortIdentifier portId;
static CommPortIdentifier saveportId;
static Enumeration portList;
InputStream inputStream;
SerialPort serialPort;
Thread readThread;
static String messageString = "AT";
static OutputStream outputStream;
static boolean outputBufferEmptyFlag = false;
public static void main(String[] args) {
boolean portFound = false;
String defaultPort;
String osname = System.getProperty("os.name","").toLowerCase();
if ( osname.startsWith("windows") ) {
defaultPort = "COM5";
} else if (osname.startsWith("linux")) {
defaultPort = "/dev/ttyS0";
} else if ( osname.startsWith("mac") ) {
defaultPort = "????";
} else {
System.out.println("Sorry, your operating system is not supported");
return;
}
if (args.length > 0) {
defaultPort = args[0];
}
System.out.println("Set default port to "+defaultPort);
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals(defaultPort)) {
System.out.println("Found port: "+defaultPort);
portFound = true;
nulltest reader = new nulltest();
}
}
}
if (!portFound) {
System.out.println("port " + defaultPort + " not found.");
}
}
public void initwritetoport() {
try {
outputStream = serialPort.getOutputStream();
} catch (IOException e) {}
try {
serialPort.notifyOnOutputEmpty(true);
} catch (Exception e) {
System.out.println("Error setting event notification");
System.out.println(e.toString());
System.exit(-1);
}
}
public void writetoport() {
System.out.println("Writing \""+messageString+"\" to "+serialPort.getName());
try {
outputStream.write(messageString.getBytes());
} catch (IOException e) {}
}
public nulltest() {
try {
serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
} catch (PortInUseException e) {}
try {
inputStream = serialPort.getInputStream();
} catch (IOException e) {}
try {
serialPort.addEventListener(this);
} catch (TooManyListenersException e) {}
serialPort.notifyOnDataAvailable(true);
try {
serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {}
readThread = new Thread(this);
readThread.start();
}
public void run() {
initwritetoport();
try {
while (true) {
writetoport();
Thread.sleep(1000);
}
} catch (InterruptedException e) {}
}
public void serialEvent(SerialPortEvent event) {
switch (event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
byte[] readBuffer = new byte[20];
int numBytes = 0;
try {
while (inputStream.available() > 0) {
numBytes = inputStream.read(readBuffer);
}
String result = new String(readBuffer);
System.out.println("Bytes read: "+numBytes+", Read contents: "+result);
} catch (IOException e) {}
break;
}
}
}
Kujtim
|
|
|
|
|
Sir, This is maheswara from A.P ...where can i get the code for band width analysis i.e it should record sent data and received data in a system with internet connection ....we have spent almost 10 days but no result plzzzzzzzz
|
|
|
|
|
Hey Maheshwara,
Nice to know that you are from A.P. But nobody (except indians) would know about that place. Well yes, and about your question, I think Google search does everything. Learn to use google to search for core programming resources sweetheart.
And how's Cheeranjivi? When is his next film gonna release?
I calculate my days on earth..... approximately 55 years remaining for me to expire
|
|
|
|
|
Hello,
I heave an array of objects which each object has some common parameters, but also is to be characterized by adequate specific object. For each object I use 'objectType' parammeter to differentiate, then the rest, I tried as follows (using 'Object' type) but it is not working. Here is the complete simplified code:
class DiffObjectClasses{
public static void main(String [] args)
{
SerialObject so;
IPObject iob;
ObjectType ot[] = new ObjectType[3];
ot[0].objectID=1;
ot[0].objectType=1;
so=new SerialObject();
so.serialPortNo=21;
ot[0].objectContent=so;
ot[1].objectID=2;
ot[1].objectType=1;
so=new SerialObject();
so.serialPortNo=21;
ot[1].objectContent=so;
ot[2].objectID=3;
ot[2].objectType=2;
iob=new IPObject();
iob.host="localhost";
iob.port=2200;
ot[2].objectContent=iob;
System.out.println("----------------------------");
for(int indx=0; indx<ot.length;indx++)
{
System.out.println("ObjID:"+ot[indx].objectID);
System.out.println("ObjType:"+ot[indx].objectType);
switch(ot[indx].objectType)
{
case 1:
so=(SerialObject)ot[indx].objectContent;
System.out.println("Serial port no:"+so.serialPortNo);
break;
case 2:
iob=(IPObject)ot[indx].objectContent;
System.out.println("IP host:"+iob.host);
System.out.println("IP port:"+iob.port);
break;
}
}
}
}
class ObjectType{
int objectID;
int objectType;
Object objectContent;
}
class SerialObject{
int serialPortNo;
}
class IPObject{
String host="";
int port;
}
I've worked in C/C++, it was very simple by declaring 'void' member and then using implicit conversion as here but it sin't working in Java.
Kujtim
|
|
|
|
|
If you declare those last two classes like so:
class SerialObject extends ObjectType{
int serialPortNo;
}
class IPObject extends ObjectType{
String host="";
int port;
}
It may work.
You generally can't cast types to each other unless they somehow derive from each other in some way (unless it's a primitive type)
|
|
|
|
|
Hello,
I just tried your suggestion but it doesn't works. Even tried extends 'Object' since is more logical.
This is the error:
Exception in thread "main" java.lang.NullPointerException<br />
at DiffObjectClasses.main(DiffObjectClasses.java:9)
Thanks anyway,
Kujtim
modified on Friday, July 10, 2009 2:24 PM
|
|
|
|
|
Oh. I don't know then. But if I may ask, why are you doing it the C way?
If you're just going to store and print them, maybe I would do something like:
interface IPrintable
{
void Print();
}
class SerialObject implements IPrintable{
int serialPortNo;
public SerialObject(int portno)
{
serialPortNo = portno;
}
public void Print()
{
System.out.println("Serial port no:" + serialPortNo);
}
}
class IPObject implements IPrintable{
String host;
int port;
public IPObject(String host, int port)
{
this.host = host;
this.port = port;
}
public void Print()
{
System.out.println("IP host:" + host);
System.out.println("IP port:" + port);
}
}
And then make an array of IPrintable 's, of course.
|
|
|
|
|
Hello and thanks for responding,
there is a list of objects (class instances) which heave few common properties (at the moment two) but they belong to certain type regarding to access they provide. These specific properties seems more logical to be organized in a class, but the objects must be encapsulated together.
More simply, let these objects be servers, so the particular object Server[i], has the properties: id (Server[i].id), type and accessobject(which can be SerialObject or IPObject).
Good and similar example is ArrayList which enables storing objects, I then 'create' instances from these objects using implicit conversion. There also figures Object type as an argument, but here that is not working.
Kujtim
|
|
|
|
|
Ok I'm not disagreeing or something like that, but, well. Why do you use a custom "type" thing when Java already provides the means to see which class an object is an instance of?
|
|
|
|
|
Thanks again,
I am experienced C/C# programmer but will try that in Java.
Kujtim
|
|
|
|
|
The operator is in C# is called instanceof in Java (saves you some googling)
|
|
|
|
|
Hello,
I just solved the problem. It was because the instance was not created with ObjectType ot[] = new ObjectType[3]; so I had to add also the lines ot[0]=new ObjectType(); , ot[1]=new ObjectType(); and ot[2]=new ObjectType(); after that.
The working code looks as follows:
class DiffObjectClasses{
public static void main(String [] args)
{
SerialObject so;
IPObject iob;
ObjectType ot[] = new ObjectType[3];
ot[0]=new ObjectType();
ot[0].objectID=1;
ot[0].objectType=1;
so=new SerialObject();
so.serialPortNo=21;
ot[0].objectContent=so;
ot[1]=new ObjectType();
ot[1].objectID=2;
ot[1].objectType=1;
so=new SerialObject();
so.serialPortNo=21;
ot[1].objectContent=so;
ot[2]=new ObjectType();
ot[2].objectID=3;
ot[2].objectType=2;
iob=new IPObject();
iob.host="localhost";
iob.port=2200;
ot[2].objectContent=iob;
System.out.println("----------------------------");
for(int indx=0; indx<ot.length;indx++)
{
System.out.println("ObjID:"+ot[indx].objectID);
System.out.println("ObjType:"+ot[indx].objectType);
switch(ot[indx].objectType)
{
case 1:
so=(SerialObject)ot[indx].objectContent;
System.out.println("Serial port no:"+so.serialPortNo);
break;
case 2:
iob=(IPObject)ot[indx].objectContent;
System.out.println("IP host:"+iob.host);
System.out.println("IP port:"+iob.port);
break;
}
}
}
}
class ObjectType extends Object{
int objectID;
int objectType;
Object objectContent;
}
class SerialObject extends Object{
int serialPortNo;
}
class IPObject extends Object{
String host="";
int port;
}
Thanks for other suggestions!
|
|
|
|
|
|
ana_ochia wrote: we have this project at school
0. Look at the top message, we are adamantly against doing homework. In the long run it does not help you and it syre as hell does not help the profession.
1. Do not try and get your message to stand out with big text. When used for a whole message, it gives the hamsters at codeproject HQ a hernia.
2. Now, work out what you want to do. Write [on paper] how your program shall work and try out something. If you get stuck, come back and ask a programming question.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
thanks...but FYI I'm not looking for other people to do my homework. I was just asking if it were possible that I can program the game. I wasn't asking for people to send me codes and stuff. I also want to learn and solve it on my own. I thought people here would help, but I guess not.
I think this will be the last time I'll post something here.
I don't want to attract attention especially with "people like you", so very close-minded, thinking that we're asking codes for homework..
thanks anyway.
PS: I did not make the text big on purpose. I can't barely see the text on my screen because my browser is Safari. Sorry if you thought I was doing that on purpose to get a coders attention. This is my first time joining in a forum like this. And I'm still new to the rules...I'll just delete my account if that makes you happy..
|
|
|
|
|
Hello,
Don't take it so badly. The problem is that there are really a lot of people who post and are just asking for finished code. I didn't see your original message but it was probably not clear and was understood as "please do the job for me" (because this is what a lot of people are asking these days). I suggest you read the posting guidelines ("How to get an answer to your question"), this will guide you a bit in formatting your question properly.
As long as you do not expect people to do the job for you and are willing to learn and work by yourself, people here will be ready to help you I'm sure.
|
|
|
|
|
There are guidlines posted at the top of all the forums here, please read them.
As Cedric said, we get too many people saking for 'da codz' and 'my homework is...' that any such question is bound to get a flipent reply. Don't take it to heart, try something out, do a little research and please come back when you are stuck.
We do WANT to help.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Not sure if this is the right place to ask the question, but here goes.
I am fairly new to working with J2EE, about a year now. I work on an existing J2EE app deployed to WL 10. At a very high level we have an enhancement project in which a back end mainframe process is going to create a dataset that is in essence a .csv file. These datasets will be created during a mainframe batch process run during certain time windows. These resulting data sets will also need to be zipped, encrypted and put onto a secure file storage mount where they can be downloaded via the web. As part of out deployment we have a server running that handles non-transactional, non-user invoked processing. It will fall to this J2EE application to handle the zip, encrypt and movement of these files to the file storage mount.
There is an option on the table to look at using MQ Series to transfer these resulting dataset (.csv) files from the mainframe to a place where the J2EE app can process (zip, encrypt, and place on file storage) the files.
So, finally to the question. As I understand MQ Series (Now MQ WebSphere or something like that), in essence it is a FIFO queue that can also provide triggering logic.
Is it possible to implement something that could monitor the MQ queue to just pull the files off the queue and process them? Or be triggered to check the MQ queue? Is this something already in the J2EE? Is this done via an api of some type? If this is possible, where is a good place to find some resources on doing something like this?
This is still in requirements and design so I don’t really have more detail at this point.
Thanks in advance for the help.
Troy
|
|
|
|
|
What you are looking for are Message Driven Beans or MDBs. Basically, they are container-managed components that sit waiting for messages to arrive on a JMS queue or topic, then they grab that message and process it and then go back to wait for the next message.
There is plenty of documentation around explaining how they work. Just Google for MDB. There are also plenty of books which cover JMS and MDBs.
WebLogic has its own JMS implementation but it is possible to use it with MQ Series. The WebLogic documentation used to include full instructions on how to do this, but I haven't used it since WL 9.2 so I don't know whether the documentation for 10 still includes this. If not, I'm sure a google search will pull up lots of examples.
|
|
|
|
|
Hi all, i downloaded the sortTable.js file from codeproject and it's working really fine. i am using an HTML table to display a MySQL data. But I need two additional things:
1) how to ignore some columns headers (the user can't click on column header to sort its values)
2) how to provide a default sort (sortTable.js sort by default the first column) but what if i need to sort the 2nd one? i tried "ORDER BY" but it's not working with our JS script.
Thanks for your help
|
|
|
|