|
And what is PDU format?
I must get a clever new signature for 2011.
|
|
|
|
|
I know PDU just as a Protocol Data Unit[^]
is this what you're thinking about?
And please explain your problem some more.
regards
Torsten
I never finish anyth...
|
|
|
|
|
Hello All,
I have created a simple Web Service in Java, which has only one class containing 4 functions, Add, Subtract, Multiply and Divide. Now I want to publish this Web Service on Tomcat Server. I am able to do it on my Localhost through Eclipse.
Can please any one tell me how should I deploy this web service as a WAR on different server and how can I access this from another server/client. In short, where I can get the URL of the web service.
Any help in this regard is appreciated.
--Thanks
Sameer
|
|
|
|
|
|
Hello,
I need to know hot to use shift operators << and >> in Java with float and double types. I tried to use them but I got compile error. I needed it for serialization data e.g. sending over the streams.
|
|
|
|
|
I do not think that Java streams allow these operators, << and >> are shift operators which is why you get compile errors.
I must get a clever new signature for 2011.
|
|
|
|
|
Both Double and Float support the longValue() method which will return you a long primitive (if it's in the range of long). The other option for bit manipulation is to use the toHexString() method on Double or Float .
|
|
|
|
|
This may be a dumb question but what does bit shifting have to do with serialization? Why would you need to shift the bits in a double value in order to send it over a stream?
|
|
|
|
|
I think the OP is getting confused with the stream operators of C++.
I must get a clever new signature for 2011.
|
|
|
|
|
|
I'm assuming that you want to use the bit-representation of the floating point value with the shift operators to create a float from a byte-stream, and vice-versa
The java Float class (here[^]) contains functions:
floatToIntBits , floatToRawIntBits -- Convert from a float to an integer containing the float value's bit representation
intBitsToFloat : Converts an integer value (containing a float value's bit representation) to a Float variable.
So basically you can do something like:
byte[] data = ...;
int rdInt = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
float rdFloat = Float.intBitsToFloat(rdInt);
... And do the opposite to convert back from float to bytes.
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
"Philosophy is a study that lets us be unhappy more intelligently."
-Anon.
|
|
|
|
|
Hi,
I installed Netbeans 6.9 and try to work on Java. at first glance I faced 2 questions?
when you open new project you see Java and java EE. what is the problem between them? what the meaning of enterprise Application?
I would please if some one who has experience help me in this matter.
|
|
|
|
|
Try the Java home page for more information on the different versions.
I must get a clever new signature for 2011.
|
|
|
|
|
'at a glance' is the keyword: Java EE at a glance[^]
Java EE @ Wikipedia[^]
So a Java-Project - is a general Java Application of some kind (not further defined).
A Java EE Project is a more specified project with predefined libraries - short and really brief described. Java EE is the counterpart to Microsoft's .net. It's used for advanced projects.
regards
Torsten
I never finish anyth...
|
|
|
|
|
java ee refers to the java enterprise edition, it's a platform for web development.
java usually refers to java standard edition,suitable for develope the basic project like swing, gui.
from china
My QQ: 233357374
|
|
|
|
|
I have this code for to create file in directory.
public class Coba {
public static void main(String[] args)throws IOException {
Writer writer = null;
try{
String text = "apa kabar";
File f = new File("d:/azhar.txt");
writer = new BufferedWriter(new FileWriter(f));
writer.write(text);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (writer != null) {
writer.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
System.out.println("file has been created in directori");
}
}
i want to ask ? how to when i run code mentioned, file in directory open automatically..anyone to help me please ??
|
|
|
|
|
I am note sure what exactly your asking, but having a guess;
The file is automatically opened by the FileWriter providing it is not already opened or cannot be created;
This is as per the specification in the java doc; FileWriter[^]
|
|
|
|
|
I mean..file is already create when i run this program,but these file not opened just created in directory. and i wanna when i run this program these file already created and opened automatical also (together).. ??
|
|
|
|
|
please make small sentences and try to explain again what you want to achieve. No one can understand this.
regards
Torsten
I never finish anyth...
|
|
|
|
|
What about this?..
Runtime.getRuntime().exec ("d:/azhar.txt");
This will do for now
|
|
|
|
|
musefan wrote: Runtime.getRuntime().exec ("d:/azhar.txt");
Iam confused where row I put this code ?
|
|
|
|
|
that's just a command forcing the OS to create the txt-file.
stick with your version and try to develop it further on.
regards
Torsten
I never finish anyth...
|
|
|
|
|
Hi to everyone,
I have three classes: Server, ThreadHandler and Client...so far I am able to connect two clients (tried only two so far as that is all i need) to the server and if i type a message in the text field am able to see the "OUTGOING msg" displayed on the text Area...but No "INCOMING msg"...and I've tried searching and couldn't find a solution please note this is for my project and I am asking for a help with solving this problem and here are the codes for each class:
----------------------------------------------------------------
Server Class = LanChatGUI.java (I left out the generated code and the imports)
public class LanChatGUI extends javax.swing.JFrame{
public static ServerSocket serverSocket = null;
public static boolean listen = true;
public LanChatGUI() {
initComponents();
}
public static void main(String args[]) throws IOException {
new LanChatGUI().setVisible(true);
try{
serverSocket = new ServerSocket(7777);
errorLabel.setText(" Waiting connection on port 7777");
}catch(IOException ex){
errorLabel.setText("Listening on port 7777 failed!");
System.exit(-1);
}
while(listen){
new ThreadHandler(serverSocket.accept()).start();
errorLabel.setText(" LocalMessenger client connected on: "
+ serverSocket.getInetAddress() + serverSocket.getLocalPort());
}
}
private javax.swing.JPanel backPanel;
private javax.swing.JLabel bottomLabel;
public static javax.swing.JButton connectButton;
public static javax.swing.JLabel errorLabel;
private javax.swing.JLabel hostlable;
public static javax.swing.JTextField hosttxt;
private javax.swing.JLabel portlabel;
public static javax.swing.JTextField porttxt;
public static javax.swing.JComboBox selectionBox;
private javax.swing.JLabel titleLabel;
ThreadHandler.java
public class ThreadHandler extends Thread {
private Socket connectionSocket = null;
public ThreadHandler(Socket connectionSocket) {
super("ThreadHandler");
this.connectionSocket = connectionSocket;
}
@Override
public void run() {
String to;
BufferedReader userInput = null;
PrintWriter userOutput = null;
try {
userInput = new BufferedReader(new InputStreamReader(
connectionSocket.getInputStream()));
userOutput = new PrintWriter(connectionSocket.getOutputStream(), true);
while((to = userInput.readLine()) != null){
userOutput.print(to);
System.out.println(to);
}
userOutput.close();
userInput.close();
connectionSocket.close();
}catch(IOException e){}
}
}
The bit that I highlighted in bold...I am not sure if tha bit of code is outputting messages sent from a client(A) to a client(B).
--------------------------------------------------------------
Client class --- ChatGUI.java
public class ChatGUI extends javax.swing.JFrame implements Runnable {
public static Socket connectionSocket = null;
public static BufferedReader userInput = null;
public static PrintWriter userOutput = null;
public static StringBuffer toAppend = new StringBuffer("");
public static StringBuffer toSend = new StringBuffer("");
public static String ipAdd = "127.0.0.1";
public static int portNum = 7777;
public ChatGUI() {
initComponents();
convtxtField.addActionListener(new ActionAdapter() {
public void actionPerformed(ActionEvent e) {
String s = convtxtField.getText();
if (!s.equals("")) {
appendToChatBox("OUTGOING: " + s + "\n");
convtxtArea.append(toAppend.toString());
toAppend.setLength(0);
convtxtField.selectAll();
sendString(s);
}
}
});
}
private static void appendToChatBox(String s) {
synchronized (toAppend) {
toAppend.append(s);
}
}
private static void sendString(String s) {
synchronized (toSend) {
toSend.append(s + "\n");
}
}
private static void closeConnection() {
try {
if (connectionSocket != null) {
connectionSocket.close();
connectionSocket = null;
}
}
catch (IOException e) { connectionSocket = null; }
try {
if (userInput != null) {
userInput.close();
userInput = null;
}
}catch (IOException e){userInput = null;}
if (userOutput != null) {
userOutput.close();
userOutput = null;
}
}
public static void main(String args[]) throws IOException {
String s;
new ChatGUI().setVisible(true);
while(true){
try{
connectionSocket = new Socket(ipAdd, portNum);
userInput = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
userOutput = new PrintWriter(connectionSocket.getOutputStream(),true);
}catch(IOException ex){
closeConnection();
}
try{
if (toSend.length() != 0) {
userOutput.print(toSend);
userOutput.flush();
toSend.setLength(0);
}
if (userInput.ready()) {
s = userInput.readLine();
appendToChatBox("INCOMING: " + s + "\n");
convtxtArea.append(toAppend.toString());
toAppend.setLength(0);
}
}catch(IOException ex){
closeConnection();
}
}
}
public static javax.swing.JMenuBar MenuBar;
public static javax.swing.JPopupMenu.Separator MenuSeparator;
public static javax.swing.JMenu aboutMenu;
public static javax.swing.JPanel convPanel;
public static javax.swing.JTextArea convtxtArea;
public static javax.swing.JTextField convtxtField;
public static javax.swing.JMenu exitMenu;
public static javax.swing.JMenu fileMenu;
public static javax.swing.JMenu helpMenu;
public static javax.swing.JMenu logoutMenu;
public static javax.swing.JScrollPane scrollpaneTextArea;
}
class ActionAdapter implements ActionListener {
public void actionPerformed(ActionEvent e) {}
}
So if I run this program the server runs 1st and waits for a client to request a connection and after the client is connected (in this case 2 clients) i type a simple msg like "Hi" from Client A and i type "hello" in Client B i see in the text Area "Outgoing: Hi" in Client A and "Outgoing: Hello" in Client B...but as mentioned above I also want the Incoming messages to be displayed in the text area which i cant figure out how to call the text area in the client class from the ThreadHandler class or mb ther is a different way of doing it so pls help...
P.S. to see if these messages are been sent to the server..in the "ThreadHandler class" i entered "System.out.println(s);" the bit coloured in red and in the console it shows messages from both clients...so as said i guess all i am missing is the "Incoming part from the server side"....I would appreciate if any1 could assist me with this!
All i need is to see incoming messages in both clients other than that everything is working... pls help as i am suppose to submit this by nxt week...
Many thanks
|
|
|
|
|
Please use <pre></pre> tags around your code (not <code>) to ensure correct formatting.
I must get a clever new signature for 2011.
|
|
|
|
|