Java and Bluetooth

I have made a bluetooth server on my pc, and a client on a mobile phone..
But I cant get it to work with multiple connections, it is only possible to have one connection at a time.
Is i possible to handle serveral connections at a time ?
I have tried using threads but it blocks the connection to the bluetooth usb dongle.

code?

Similar Messages

  • Ubuntu and API bluecove : java and bluetooth

    Hi
    Here is my final project I want study worked with bluecove api (java bluetooth technology) and J2ME you guessed I am looking to make contacts and nokia laptop via bluetooth
    then voila I first exposed my equipment:
    hp laptop duel core processor, 200 gig hard drive, 2 GB rowing bone ubuntu 10.10 and set a date and I installed the bluetooth driver that ubuntu recommended me short I followed this short course:
    http://myexp101.wordpress.com/2011/11/11/develop-java-bluetooth-application-under-ubuntu-linux/
    for the library installed on ubuntu bluecove then I tested a small java program:
    http://www.miniware.net/mobile/programs/EchoServer.java
    to see that Bluetooth is enabled and can detect the presence of mobile phone nokia
    I created a test project in eclipse and I joined the library in my project brief bluecove here is the program:
    import java.io.*;
    import javax.bluetooth.*;
    import javax.microedition.io.*;
    public class EchoServer {
    public final UUID uuid = new UUID( //the uid of the service, it has to be unique,
                   "27012f0c68af4fbf8dbe6bbaf7aa432a", false); //it can be generated randomly
    public final String name = "Echo Server"; //the name of the service
    public final String url = "btspp://localhost:" + uuid //the service url
    + ";name=" + name
    + ";authenticate=false;encrypt=false;";
    LocalDevice local = null;
    StreamConnectionNotifier server = null;
    StreamConnection conn = null;
    public EchoServer() {
    try {
    System.out.println("Setting device to be discoverable...");
    local = LocalDevice.getLocalDevice();
    local.setDiscoverable(DiscoveryAgent.GIAC);
    System.out.println("Start advertising service...");
    server = (StreamConnectionNotifier)Connector.open(url);
    System.out.println("Waiting for incoming connection...");
    conn = server.acceptAndOpen();
    System.out.println("Client Connected...");
    DataInputStream din = new DataInputStream(conn.openInputStream());
    while(true){
    String cmd = "";
    char c;
    while (((c = din.readChar()) > 0) && (c!='\n') ){
    cmd = cmd + c;
    System.out.println("Received " + cmd);
    } catch (Exception e) {System.out.println("Exception Occured: " + e.toString());}
    public static void main (String args[]){
    EchoServer echoserver = new EchoServer();
    here is the result of the execution in eclipse:
    Setting device to be discoverable...
    BlueCove version 2.1.1-SNAPSHOT on bluez
    Exception Occured: javax.bluetooth.BluetoothStateException: Bluetooth Device is not ready. [1] Operation not permitted
    BlueCove stack shutdown completed
    Do you have an idea for solving the problem?
    cordially

    As I can judge, it is not just simple XML. An
    ODS-File contains some XML in just one file. It is
    not enough, just to parse it once with an XML. Is
    there any APIs I could use, to read the field values,
    or I have to write it myself?
    I don't know why, but if I google for java api and
    ods, openoffice etc. there is no information I need
    :-((As I said, I've not had the need to do it myself, but as this is one of the primary benefits of the ODF, it shouldn't be too taxing. The format seems to be pretty well documented (try the OO website.....I'm sure theres a developers section), so even if you had to write a parser yourself, I doubt it would be terribly difficult. Sorry I can't be of more help.

  • PocketPC / Java and BlueTooth

    I am running a Java application on a Pocket PC with Jeode. Part of the applications functionality ftps' some data to and from a specified ftp site. At the moment when the application is running, if it tries to make an ftp connection it fails if there is no existing blue tooth dial up connection. If, however, IE has peviously been launched on the PocketPC, the connection is available and the application will successfully ftp files.
    Does anyone know how to force an ftp connection over Blue Tooth from within a Java application running on a Pocket PC? I am new to this type of platform so I'm not 100% clear how these technologies work together...
    Cheers

    I had the same problem for an XDA (Pocket PC 2002).
    You should make a native (Runtime.getRuntime().exec("..")) call from Jeode to dial up. Unfortunately Jeode doesn't support this functionality without additional C code (a windows binary library), this is due to a problem with Pocket PC not implementing certain features so I am told.
    Although a patch received from Insignia/Esmertec should work in theory I was unable to get it working (the code is available in similar posts in this forum or email me for the binary).
    The CrEme VM does not have this restriction and will allow you to make the native call to start your connection. To open a connection you could call a shortcut directly with the dialup code in it like this:
    Java:
    Runtime.getRuntime.exec("\\windows\startmenu\myshortcut.lnk") ;
    Contents of the shortcut (myshortcut.lnk):
    28#\Windows\rnaapp.exe -p -e"<your dialup connection name here>"
    Running it again will disconnect.
    Hope this helps.

  • MIDP and Bluetooth as Java Card substitute

    Hi,
    I'm a Java developer, but not a Java Card developer, so I'm curious about the opinions of Java Card developers. It seems to me that IR and Bluetooth enabled J2ME/MIDP devices could be used in many situations where Java Cards are currently used. Depending on the adoption rates of
    a) Bluetooth enabled computers, devices, access points, etc... and
    b) cell phones with both Bluetooth and J2ME
    It may soon (a year or two) become cheaper and/or more convenient to issue users without a J2ME Bluetooth phone, such a device, than to issue all users Java Cards.
    So, entrenched coders
    1) Is this migration sane?
    2) Is anybody doing it, now?
    3) How hard/trivial is porting the applications?
    Thanks,
    Curt

    I'm aware of the JSR, but what is the security element ?On Sun Tech Days I was told it should be a Java Card. ;-))
    The main advantage of a smartcard is that it provides a trustworthy and tamper-resistant environment.
    Please have a look at
    http://www.simalliance.org/portal_upload/SIMalliance_comm.PDF
    I quote from the SIM Alliance site:
    "Thanks to a defined standard, easy downloading and powerful operating systems displaying high quality graphics, J2ME phones are making their mark. This leads to the question with such success and a memory capacity up to 1000 times the (U)SIM, will this relegate the Smart Card to a second class citizen?
    While Smart Card cannot compete with a Java handset for the sexy aspects of applications such as graphics, the core attributes of a Smart Card offer a number of significant benefits to application delivery, execution and management. All of these features require privacy management, security, portability and one-to-one personalization.
    Wireless applications must be secure and robust. However, it is feared that operators' revenue streams and secure pipeline will be threatened by the free delivery of applications mimicking the loss-making Internet portal model.
    This is where the Smart Card, (UICC, (U)SIM, and equivalent), will play an essential role in providing security, building trust and protecting revenues for mobile businesses.
    The card will become an integral part of the architecture for distributed applications running at the same time on Server, Handset and Smart Card to leverage the respective benefits of each part of the infrastructure.
    By looking at the strong points of each of the Java standards, Java Card and J2ME are not competing technologies but instead can be used in tandem to create an "open" and "secure" infrastructure that operators and content providers need in order to increase their ARPU and diminish costs. At present this infrastructure does not exist but leading operators, handset manufacturers, content providers and (U)SIM suppliers are working to make it a reality."

  • Guide for J2ME PP to use RMI and Bluetooth

    hi
    i have a current project its about an Ordering System, and i was thinking of using ppc as an order client
    before i want to get on with this i was just wondering if i can get some help from here.
    i just want to ask would it be any problem if i use J2SE to write a server to communicate with the ppc using rmi methology and bluetooth as network device (USB bluetooth for PC). can some one please give me some direction of how to do it, or maybe there's a beta way to do something like this?
    do i just write the code as how you would normally write for rmi application for PC?
    do i need to use third party driver for bluetooth (PC and PPC)?
    btw my PPC is HP Pocket PC 2003 running Window CE and use J9 JVM
    thank you for in advance as i would really appreciate and so is others :)

    Hi,
    I have the same message "Error: Unable to query value..."
    But I can't read from serial port com8. I need to read data from gps, but first I want to read anything from com8.
    My application looks like that:
    import java.util.*;
    import javax.comm.*;
    import java.io.*;
    public class Porty {
    static CommPortIdentifier portId,tym;
    static Enumeration portList;
    private InputStream cos;
    private SerialPort porty;
    public Porty(){
         CommPortIdentifier portID = null;
         for (Enumeration portList = CommPortIdentifier.getPortIdentifiers();
              portList.hasMoreElements() ;) {
         CommPortIdentifier portId = (CommPortIdentifier)portList.nextElement();
         if (portId.getName().equals("COM8:")) {
              tym = portId;
         if (tym == null) {
         // Unable to find COM8
              System.out.println("No Com8");
         return;
         else {
         // found COM8
              System.out.println("Yes!!! Com8");
         try{
              cos = porty.getInputStream();
         }catch (IOException e){}
         System.out.println("Data from Com8");
         System.out.println(cos);
    public static void main(String[] args){
         Porty porcik = new Porty();
    What is wrog. Could samebody help me !!! What I suppouse to do !!! Could You send me same application, which is working and it reads from port.
    Thank You...

  • We just added a new printer and bluetooth connection to our iMac.  Now iTunes does not recognize our iPads as devices.  Have already tried restarting everything.  Any other suggestions?

    We just added a new printer and bluetooth connection to our iMac.  Now iTunes does not recognize our iPads as devices.  Have already tried restarting everything.  Any other suggestions?

    You can try the steps recommended here: http://www.apple.com/support/ipad/assistant/itunes/

  • ABAP , JAVA And XSLT Mapping Doc's

    Hi,
    I am new to SAP XI Any body please send me the Doc's Related to ABAP, JAVA And XSLT Mappings. Thanks in Advance.
    Regards
    Kiran.B

    Hi
    Refer to
    ABAP mapping:
    How to Use ABAP Mapping in XI 3.0
    JAVA mapping:
    http://help.sap.com/saphelp_nw04/helpdata/en/bd/c91241c738f423e10000000a155106/frameset.htm (Java mapping)
    XSLT mapping:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/01a57f0b-0501-0010-3ca9-d2ea3bb983c1
    /people/prasadbabu.nemalikanti3/blog/2006/03/30/xpath-functions-in-xslt-mapping
    /people/sreekanth.babu2/blog/2005/01/05/design-time-value-mappings-in-xslt
    /people/anish.abraham2/blog/2005/12/22/file-to-multiple-idocs-xslt-mapping
    XSLT Mapping with java enhancement
    /people/pooja.pandey/blog/2005/06/27/xslt-mapping-with-java-enhancement-for-beginners
    XSLT - /people/dirk.roeckmann/blog/2006/07/26/grouping-xml-with-xslt--from-muenchian-method-to-xslt-20
    Regards,
    Kumar.
    Reward points if helpful!!

  • BI Java and BI ABAP -RSPLAN issue

    Hi All
    We are working with BI system ,using BI 7.0 Java and BI ABAP as separate systems on same host.
    Already run the template intaller for BI Java and ABAP integration.
    But facing some issue ,when going ot BI ABAP and RSPLAN and clicking the Start Mideller
    it is opening a browser as http://host:8000/sap/public/myssocntl?sap-client-XXX
    Since this is not correct and it should open BI Java portal instead of ABAP stack page.
    Instead this should open a Url like this http://host:5XX00/webdynpro/dispatcher/sap.com/biplanworkbench1/Modeler?
    I check on BI ABAP system under SAP Reference IMG -> SAP Customizing Implementation Guide-> SAP NetWeaver _> Business Intelligence-> BI Integrated Planning -> Settings for Starting the Planning Modeler.
    There the default Url is BEx Portal Server and the url is        
    http://host:5XX00/webdynpro/dispatcher/sap.com/biplanworkbench1/Modeler
    Can anybody let me know why this is going to ABAP server instead it should go to Java.
    Regards
    Ajay
    Edited by: Ajay Sandal on Mar 10, 2009 2:31 PM

    Hi Ajay ..
    Good news that ur issue is resolved ..
    I have somewhat similar issue .. Hopu u can put some light ..
    I have Bi 7.o with Add on java  ,
    In RSPLAN from ABAP system , modular page is not coming . if i click on start moduler button in RSPLAN ..portal page is coming up and i have to give logging details .
    Please suggest .
    Thanks

  • Has anyone else downloaded iOS 7 on a 4S and found the WiFi and Bluetooth don't work anymore?

    I'm used to Apple products that "just work", but I'm not seeing it with the installation of iOS 7 on my phone (4S). I installed it earlier today, and the Wi-Fi and Bluetooth worked for about an hour, then just quit working altogether. The WiFi button is grayed out in Settings, and Bluetooth dosen't even display a button (all I get is a throbber that continuously spins). Trying to activate them through the "swipe-up" command center doesn't do the trick, and resetting the network settings also accomplishes nothing. Several reboots later, and I still don't have WiFi and Bluetooth.
    Has anyone else experienced this, and is there a solution? I may just decide to eschew iOS 7 and restore my pph

    After multiple attempts to restore and reboot, I finally decided to take a trip to my local AT & T store. They contacted Apple, and I explained the situation. I ended up moving to the iPhone 5, as my 4S was in the renew period. The 4S is still under warranty, so all I have to do is bring it to an Apple Store, where they will either fix or replace the phone. Looks like one of my kids will be getting a 4S :-)

  • How to get return value from java and read by other application?

    i want to read return value from java and the other application read it.
    for example:
    public class test_return {
        test_return(){
        public int check(){
            return 1;
        public static void main(String args[]){
           new test_return().check();
    }from that class i make as jar file. How to read the return value (1) by other application?
    thx..

    If your installer is requiring some process it invokes to return a particular value on failure, then the installer is seriously broken. There are a bazillion commands your installer could invoke, and any of them could fail, which in turn could invalidate the entire install process, and any of them could return any value on failure. The only value that's consistent (in my experience) is that zero means success and non-zero means failure, with specific non-zero values being different in different programs.
    About the only control you have over the JVM's exit code is that if your main method completes without throwing an exception, the JVM will have an exit code of 0, and if main throws an exception (either explicitly or by not catching one thrown from below), it will be non-zero. I'm not even sure if that's guaranteed, but I would guess that's the case.
    EDIT: I'm kind of full of crap here. If you're writing the Java code, you can call System.exit(whatever). But nonetheless, if your installer requires certain exit codes from any app--java or otherwise--you have a problem.
    Edited by: jverd on Oct 29, 2009 1:27 AM

  • Problem with java and flex web service

    Hi,
    I have a basic web service written in java using jax ws 2.1
    ri. I need to call it from Flex using the WebService class
    Annotations for the java web method :
    @WebMethod
    public void Login(
    @WebParam(name="server") String serverURL,
    @WebParam(name=AUTHENTICATE_HEADER,header=true,mode=WebParam.Mode.INOUTHolder<Authenticate Header>
    authHeader)
    When I try and call the service from Flex , it can't find the
    login method and attempts to call it fail. If I set the web service
    to RPC based using @SOAPBinding , the method is found but then
    there are issues with the authentication header.
    What do I need to do to get flex web services communicating
    succesfully with java ?
    Are there are any known compatibility issues ? Or guidelines
    for going about this ?
    Any help would be appreciated

    well Shay,
    i've used JDev's tools to developer and to deploy the web service: the war and ear files are automatically generates you to the end of the process.
    I have included all the files java and the compiled classes, but I do not have files jar.
    But don't works: if i create only one java class with all code inside then it works fine!!
    Daniele

  • Problem with java and javaw

    Hi,
    In running the following simple code, I have gotten different results using java and javaw.
    public class Test {
    public Test() {
    public static void main(String[] args) {
    int x =4;
    System.out.println("The value is "+ ((x > 5)?6.0:4));
    System.out.println("The value is "+ ((false)?6.0:4));
    System.out.println("The value is "+ ((true)?99:9.9));
    Using java, I get the following results:
    The value is 4.0
    The value is 4.0
    The value is 99.0
    But using javaw, I get the following results:
    The value is 4.0
    The value is 4
    The value is 99
    Any ideas why this is so?
    Thanks for any help.
    Gilbert

    I used JBuilder to run the following code and Jbuilder uses javaw.
    By the way, the correct answer is the one using java right?

  • Problem with Java and Zip Files

    Hello there everyone. I have a problem with trying to zip up directories with empty folders in them. They zip fine with my code, but according to winzip, the number of files in the archive is incorrect. It's supposed to have a total of 288 files in it, but when it's zipped up, it only says 284. I mention specifically the "empty directories" note because the zipping works fine without empty folders.
    Below is the code for the zip method:
    public static void zip(File[] list, File zipfile, File zipRoot)
         throws IOException {
          if (!zipfile.exists()) {
                   zipfile.createNewFile();
              else if (!zipfile.isFile()) {
                   throw new IOException("The zip file, " + zipfile.getAbsolutePath()
                             + " is not a file.");
              if (list.length == 0) {
                  LOG.error("The list of files to zip up is empty.");
              for (int i = 0; i < list.length; i++) {
                   if (!list.exists()) {
                        throw new IOException("The file or directory, " + list[i].getAbsolutePath()
                                  + " does not exist.");
              FileOutputStream fos = new FileOutputStream(zipfile);
              ZipOutputStream zos = new ZipOutputStream(fos);
              for (int i = 0; i < list.length; i++) {
                   if (LOG.isDebugEnabled())
                        LOG.debug(i + ": " + list[i].getName());
                   String entryName = getRelativeName(list[i], zipRoot);
                   if (list[i].isDirectory()){
                        if (list[i].listFiles().length == 0){
                             ZipEntry entry = new ZipEntry(entryName + "/");
                             zos.putNextEntry(entry);
                   else {
                        ZipEntry ze = new ZipEntry(entryName);
                        zos.putNextEntry(ze);
                        byte[] buffer = new byte[8096];
                        FileInputStream fis = new FileInputStream(list[i]);
                        int read = 0;
                        read = fis.read(buffer);
                        if (LOG.isDebugEnabled())
                        LOG.debug("\tFound " + read + " bytes.");
                        if (read == -1){
                             //empty file, but add it for preservation.
                             //zos.write(buffer,0,0);
                        while (read != -1) {
                             zos.write(buffer, 0, read);
                             read = fis.read(buffer);
                        fis.close();
                        zos.closeEntry();
              zos.close();
    The files look like they're there, but I need the system to be able to determine the number correctly. 
    Here's the interesting thing:  It zips the files, and then when I use the size() method for zip files in java, it says 284 files.  But when I unzip, it says 288 again.  It's like there's files missing when compressed, but when decompressed, they return.  Note that the files are actually there.  If I open the archive in a third party app such as Winzip AND Winrar AND IZarc, they all show 288 files.  Any idea what would make the number of files appear incorrectly in a zip file when zipped by java with the code above?  Thanks in advance.
    - Chris                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    I figured out the problem. When zipping files in windows using winzip, it doesn't explicitly count folders as a "file/folder" as a file in itself. It will create the folders for files to go in, but the folder itself will not be 'counted' when you query the info of the file itself. You have more control of the zip file in java, and can count the folder as a file or not.

  • Problem with java and pogo games

    i use mozilla and now with the problems with java and hackers cannot play my pogo games,what can i do? i disabled my java i tried java 6 doesnt work or is not safe,what is a safe way to play games on pogo that use java?

    Oracle has released a Java 7 Update 11 to address security vulnerabilities and you should update to that version.
    *https://support.mozilla.org/kb/how-to-use-java-if-its-been-blocked
    See also:
    *http://kb.mozillazine.org/Java#Windows_installation_issues
    You can find the latest Java version on the Oracle website.
    See Java Platform > Java SE 7U11 and Java 6U38 (Download JRE)
    *http://www.oracle.com/technetwork/java/javase/downloads/index.html

  • Compability problem with Java and Python  RSA algorithm implementation

    I have client server application. Server is writtein in python, client in java. Client receives messages from server encrypted with RSA (http://stuvel.eu/rsa), and I'm unable to decrypt it. It seems that this is RSA algorithm compatibility problem. I'm using algorithm from java.security package, instatinating Cipher object like this: c = Cipher.getInstance("RSA"); . I noticed that this algorithm produces for input blocks of lengtrh <=117 ouput block of length 128. Server I guess uses the most triviall impelentation of RSA ( (1 byte is encrypted to 1 byte) So i want to make my java algorithm compatibile with this one which server uses. How to do that ? Do i have to instatinate Cipher object in different way ? Or use another library ?

    azedor wrote:
    First you said it was no good because it could only handle <= 117 byte inputs, now you say it is no good because it produces a 128-byte output. You're not making sense.First i said that this two RSA implementations are not compatibile, and first reason i noticed firstly is that Python imlementation for input of length N produces cryptogram of the same length. Not true. In general, the RSA encryption of any number of bytes less than the length of the modulus will produce a result of length near that of the modulus. When N is less than the length of the modulus, it is rare that N bytes of cleartext produces N bytes of ciphertext.
    Java implementation for data block of length <=117 produces alwasy 128 bytes of output.Pretty much correct and very much desirable. This is primarily a function of the PKCS1 padding which is used to solve two basic problems. First, as I alluded to in my first response, it is the nature of the algorithm that leading zeros are not preserved and second when the cleartext is very small (a few bytes) the exponentiation does not roll over and it is easy to decrypt the result. Both these problems are addressed by PKCS1 padding.
    >
    >
    After what sabre150 said i think of giving up idea of translating Python code to Java and considering to use another assymetric cryptography algorithms on both sides. Can you recommend me sth what should be compatibile with Python ?This seems to be at odds with your statement in reply #3 "Also have acces only to client code so i have to change sth in java." ! This statement is why I said "I suspect ... you have dug a deep hole".
    In your position I would use the Python bindings for openssl. Once more, Google is your friend.

Maybe you are looking for