Java applet - how to do this?

I am translating a Midlet project to JApplet project. Microedition, UDPDatagramConnection, not available and lots more. How can tune this for JavaSE?
// code..........
package sip;
import javax.swing.JApplet;
import javax.microedition.io.*;
//import javax.microedition.midlet.*;
//import javax.microedition.lcdui.*;
import java.io.*;
import net.*;
import iax.audio.*;
//import iax.audio.gsm.*;
//import rtp.*;
public class InviteMIDlet extends JApplet implements CommandListener, SIPProviderListener {
// Vaiables to assign
private Display display;
public Form form;
private TextField To;
private Command sendCmd;
private Command exitCmd;
private Command hangupCmd;
public int sdpPort = 0;
private UDPDatagramConnection rtpCon = null;
private boolean incall = false;
// Sip Digest parameters
private String UserName = "";
private String passwd = "123";
private String SipServerIP = "212.";
private int SipServerPort = 5060;
// Sip parameters
private SIPProvider provider;
private String MediaIP = null;
private int MediaPort = 0;
// Thread assign
private UDPSend udpSend;
private UDPReceive udpReceive;
private AudioCapture audioCapture;
private AudioPlayer audioPlayer;
// End of Thread assign
// Main midlet parameters
public InviteMIDlet() {
form = new Form("SIP Dialer");
try {
display = Display.getDisplay(this);
To = new TextField("To:", "0012127773456", 40, TextField.LAYOUT_LEFT);
form.append(To);
sendCmd = new Command("Call", Command.ITEM, 1);
form.addCommand(sendCmd);
hangupCmd = new Command("Hangup", Command.ITEM, 2);
form.addCommand(hangupCmd);
exitCmd = new Command("Exit", Command.EXIT, 3);
form.addCommand(exitCmd);
form.setCommandListener(this);
rtpCon = (*UDPDatagramConnection*) Connector.open("datagram://:");
sdpPort = rtpCon.getLocalPort();
provider = new SIPProvider(UserName,passwd,SipServerIP, SipServerPort, 1225);
provider.start();
provider.addSIPProviderListener(this);
} catch (Exception ex1) {
ex1.printStackTrace();
}

shamuntoha wrote:
UDPDatagramConnection is available under MIDP/Midlet. But after migration to j2se, it shows microedition does not exist. What is that mean?.. None of the J2ME (or JME - I forget what they're calling it this instant) classes are available in J2SE ((J)Applets, (J)Frames etc.).
Usually there is a J2SE equivalent. The JavaDocs for J2SE are available for download, or for web browsing at [http://java.sun.com/javase/6/docs/api/index.html]. I say usually since I can find no letter for letter equivalent of UDPDatagramConnection in the J2SE. There are a variety of classes that mention Datagram. Perhaps if you start there, you will figure how to do what J2ME does.
..i want to switch the same code, concept, in to j2se.
rtpCon = (UDPDatagramConnection) Connector.open("datagram://:");
sdpPort = rtpCon.getLocalPort();BTW - the advice to use code tags still stands. Most people will not so much as glance at code that is not formatted. After all, which is easier to read, this..
rtpCon = (UDPDatagramConnection) Connector.open("datagram://:");
sdpPort = rtpCon.getLocalPort();
..or this?
rtpCon = (UDPDatagramConnection) Connector.open("datagram://:");
sdpPort = rtpCon.getLocalPort();

Similar Messages

  • In a java applet , how to call other jar file?

    i have i programm, this programm is a java application,
    also, i already put these program into jar file, and then if i double this jar file , its work!
    but , now i need to run this program in web browser,
    i thing that i will write a simple applet with a button
    after i click this jButton, how the java applet call and run the java file?
    please help me.. it is because this is my project! thx..........
    [email protected]

    I have a solution write one batch file in that you specify class path and java home.
    then give
    java -jar Test.jar
    then call this batch file from program using Java runtime
    Runtime.exec method...
    Hope will this work

  • Backspace in JAVA Applet - How to fix

    I am running RedHat 7.2 and everything on my keyboard works normally.
    However, when I start the Crossword Puzzle applet (in the Games section) in Yahoo, the Backspace key does not function the same way as it does everywhere else. In particular, I have to use the Ctrl-H keys to perform a move left + character delete.
    Is this a problem isolated to this applet (Crossword Puzzle) or is there a general place to look to set the keyboard keys when a Java applet is running?
    Thanks in advance for any help.
    Donald

    I have tried most of the browsers in both RedHat 7.2 and Mandrake 8.2, and with both Gnome and KDE desktops. Some of the browsers would not run the applet.
    I have the problem with Netscape 6.22, with Java plugin 1.3.1_02-b02
    This browser is the latest version. I am not sure about the Java plugin.
    Regards,
    Donald

  • BO XI R2 Java Admin - how to accss this

    I don't find "All Programs  ->  Business Objects  XI R2 -> Business Objects Enterprise -> Business Objects Enterprise Java Admin".
    I suspect some how it got removed.
    Could you tell me how to access this? the full URL
    http://<servername>/.....
    I don't see see "Java admin"

    http://yourservernamehere:8080/businessobjects/enterprise115/adminlaunch/launchpad.html

  • Error message: "Java Script turned off, Enable Java Script" How to do this? I have gone into "Tools--then Options--Then checked Java Script--Then the "OK/Save" Button but this has not helped. What is the right course of action?

    Java Script is disabled on my HP laptop. I have done the obvious things. It still will not enable Java Script. What do I try next?

    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]
    * [[Troubleshooting plugins]]
    If it does work in Safe-mode then disable all extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    * Use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    * Close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")

  • How to sign java applet policy to end user?

    i have putted my applet class on server, i want all end users can access it on server, how to sign the java.policy to there JRE?
    can anyone help me?

    I found this some where else. It shows how to sign an applet.
    START OF DOC
    How To Sign a Java Applet
    The purpose of this document is to document the steps required to sign and use an
    applet using a self-signed cert or CA authorized in the JDK 1.3 plugin.
    The original 9 steps of this process were posted by user irene67 on suns message forum:
    http://forums.java.sun.com/thread.jsp?forum=63&thread=132769
    -----begin irene67's original message -----
    These steps describe the creation of a self-signed applet. This is useful for testing purposes. For use of public reachable applets, there will be needed a "real" certificate issued by an authority like VeriSign or Thawte. (See step 10 - no user will import and trust a self-signed applet from an unkown developer).
    The applet needs to run in the plugin, as only the plugin is platform- and browser-independent. And without this indepence, it makes no sense to use java...
    1. Create your code for the applet as usual.
    It is not necessary to set any permissions or use security managers in
    the code.
    2. Install JDK 1.3
    Path for use of the following commands: [jdk 1.3 path]\bin\
    (commands are keytool, jar, jarsigner)
    Password for the keystore is any password. Only Sun knows why...
    perhaps ;-)
    3. Generate key: keytool -genkey -keyalg rsa -alias tstkey
    Enter keystore password: *******
    What is your first and last name?
    [Unknown]: Your Name
    What is the name of your organizational unit?
    [Unknown]: YourUnit
    What is the name of your organization?
    [Unknown]: YourOrg
    What is the name of your City or Locality?
    [Unknown]: YourCity
    What is the name of your State or Province?
    [Unknown]: YS
    What is the two-letter country code for this unit?
    [Unknown]: US
    Is CN=Your Name, OU=YourUnit, O=YourOrg, L=YourCity, ST=YS, C=US
    correct?
    [no]: yes
    (wait...)
    Enter key password for tstkey
    (RETURN if same as keystore password):
    (press [enter])
    4. Export key: keytool -export -alias tstkey -file tstcert.crt
    Enter keystore password: *******
    Certificate stored in file tstcert.crt
    5. Create JAR: jar cvf tst.jar tst.class
    Add all classes used in your project by typing the classnames in the
    same line.
    added manifest
    adding: tst.class(in = 849) (out= 536)(deflated 36%)
    6. Verify JAR: jar tvf tst.jar
    Thu Jul 27 12:58:28 GMT+02:00 2000 META-INF/
    68 Thu Jul 27 12:58:28 GMT+02:00 2000 META-INF/MANIFEST.MF
    849 Thu Jul 27 12:49:04 GMT+02:00 2000 tst.class
    7. Sign JAR: jarsigner tst.jar tstkey
    Enter Passphrase for keystore: *******
    8. Verifiy Signing: jarsigner -verify -verbose -certs tst.jar
    130 Thu Jul 27 13:04:12 GMT+02:00 2000 META-INF/MANIFEST.MF
    183 Thu Jul 27 13:04:12 GMT+02:00 2000 META-INF/TSTKEY.SF
    920 Thu Jul 27 13:04:12 GMT+02:00 2000 META-INF/TSTKEY.RSA
    Thu Jul 27 12:58:28 GMT+02:00 2000 META-INF/
    smk 849 Thu Jul 27 12:49:04 GMT+02:00 2000 tst.class
    X.509, CN=Your Name, OU=YourUnit, O=YourOrg, L=YourCity, ST=YS, C=US
    (tstkey)
    s = signature was verified
    m = entry is listed in manifest
    k = at least one certificate was found in keystore
    i = at least one certificate was found in identity scope
    jar verified.
    9. Create HTML-File for use of the Applet by the Sun Plugin 1.3
    (recommended to use HTML Converter Version 1.3)
    10. (Omitted See Below)
    -----end irene67's original message -----
    To make the plug-in work for any browser you have two options with the JDK 1.3 plugin.
    1) Is to export a cert request using the key tool and send it to a CA verification source like verisign.
    When the reponse comes back, import it into the keystore overwriting the original cert for the generated key.
    To export request:
    keytool -certreg -alias tstkey -file tstcert.req
    To import response:
    keytool -import -trustcacerts -alias tstkey -file careply.crt
    An applet signed with a cert that has been verified by a CA source will automatically be recognized by the plugin.
    2) For development or otherwise, you may want to just use your self-signed certificate.
    In that case, the JDK 1.3 plugin will recognize all certs that have a root cert located in the JDK 1.3 cacerts keystore.
    This means you can import your test certificate into this keystore and have the plugin recognize your jars when you sign them.
    To import self-signed certificate into the cacerts keystore, change directory to where the JDK plugin key store is located.
    For JDK 1.3.0_02: C:\Program Files\JavaSoft\JRE\1.3.0_02\lib\security
    For JDK 1.3.1: C:\Program Files\JavaSoft\JRE\1.3.1\lib\security
    Import your self-signed cert into the cacerts keystore:
    keytool -import -keystore cacerts -storepass changeit -file tstcert.crt
    (the password is literally 'changeit')
    Now, regardless of which method you use, the applet should be recognized as coming from a signed jar. The user can choose to activate it if he / she chooses. If your applet uses classes from multiple jars, for example Apache's Xerce's parser, you will need to sign those jars as well to allow them to execute in the client's brower. Otherwise, only the classes coming from the signed jar will work with the java.security.AllPermission setting and all other classes from unsigned jars will run in the sandbox.
    NOTE: Unless otherwise specified by the -keystore command in all keytool and jarsigner operations, the keystore file used is named '.keystore' in the user's home directory.
    The first time any keystore is accessed (including the default) it will be created and secured with the first password given by the user. There is no way to figure out the password if you forget it, but you can delete the default file and recreate it if necessary. For most operations, using the -keystore command is safer to keep from cluttering or messing up your default keystore.

  • How to retrieve data from php to a java applet?

    hi! wer having this project on printing jar files and reports..where these reports are generated from php. data will be passed as objects to the java applet. how r we suppose to do this? can someone pls explain it to me further and clearly? many thanx.. :) God bless!

    What? Is the php page going to send Java objects?

  • How can I use HyperLink In Java Applet..

    I am new In Java Programming And i Want to create a Hyperlink OR URL in java Applet, How can be It possible?

    well u can use a hyperlink as a url by using url from java.net.url class
    define ur url .... u can check the API fo r that
    and by using wht u mean .. u want to browse in applet with that url or wht
    if u want to do browing in applet than u will also have to do parsing of all HTML tags
    hope it will help u

  • Can anyone help with the java applet issue

    Hello everyone,
    This is my first thread in this forum,
    I need a little help with the form developer...
    I have oracle 9i db , 9i form developer
    I don't want to run the form i created as a java applet
    HOW IS THAT DONE i.e NOT IN THE INTERNET EXPLORER?????????
    ***IF ITS POSSIBLE

    Hello,
    I don't want to run the form i created as a java applet
    No chance, because the Web Forms client is an applet and cannot be anything else.
    Francois

  • Java Applets not working with Firefox 5 properly

    Java Applets work sometime. But after sometime the Java icon at the bottom (near date & time) disappears. After this no matter what I do it does not work. Java Applets are used in this case to draw charts. The same charts come out properly in Internet Explorer. But I prefer using Firefox for its speed. What is the reason for this problem ?

    -> Tap ALT key or press F10 to show the Menu Bar
    -> go to Help Menu -> select "Restart with Add-ons Disabled"
    Firefox will close then it will open up with just basic Firefox. Now do this:
    -> Update ALL your Firefox Plug-ins https://www.mozilla.com/en-US/plugincheck/
    -> go to View Menu -> Toolbars -> unselect All Unwanted toolbars
    -> go to Tools Menu -> Options -> Content -> place Checkmarks on:
    1) Block Pop-up windows 2) Load images automatically 3) Enable JavaScript
    -> go to Tools Menu -> Options -> Privacy -> History section -> ''Firefox will: '''select "Remember History"'''''
    -> go to Tools Menu -> Options -> Security -> place Checkmarks on:
    1) Warn me when sites try to install add-ons 2) Block reported attack sites 3) Block reported web forgeries 4) Remember Passwords for sites
    -> Click OK on Options window
    -> click the Favicon (small drop down menu icon) on Firefox SearchBar (its position is on the Right side of the Address Bar) -> click "Manage Search Engines" -> select all Unwanted Search Engines and click Remove -> click OK
    -> go to Tools Menu -> Add-ons -> Extensions section -> REMOVE All Unwanted/Suspicious Extensions (Add-ons) -> Restart Firefox
    You can enable your Known & Trustworthy Add-ons later. Check and tell if its working.

  • Industry use for java applets?

    I have been writing an applet for my fantasy football league that uses a mysql database. I am doing this to learn java. My counselor from NC State referred me to some guy looking for a web programmer. He called me up and I was able to get him to come over to the house just a minute ago. His company wanted a website to be used only by his employees as they called customers and asked if they had any metal cutting equipment they wanted to sell or buy.
    He wasnt very computer savy but insisted the site be done with ASP or.NET.
    My question is this....
    Why would a java applet not suffice for this problem? I even offered to do it free for something to put on my resume(maybe this was my mistake). I am planning on learning JSP/J2EE very soon as I am almost finished my my applet.
    I am just wondering what would be the problem with doing this as an applet.
    I told him I could do it in a week as I know I could. Why do companies insist on using technologies they dont really need? Or am I not seeing something here? Any feedback appreciated...
    [email protected]

    Companies insist on using technologies that they don't really need for three reasons:
    1) (a good reason) They've already paid for some equipment or licenses and want to exploit those purchases. Introducing a new technology would require new expenditures. (This isn't applicable if the new technologies are free, of course.)
    2) (a good reason) Their current staff already know a particular technology, and so they insist on doing new work in that technology to reduce maintenance issues. If everyone at the company knows .Net and you do something in J2EE, then in the future any maintenance would require either training, or hiring an outside consultant to do the maintenance. This costs money.
    3) (the bad, but sadly most common reason) They're stupid. They read a sales pitch from Microsoft that says "J2EE bad, .Net good" and they believe it. Or they just love everything from Microsoft, because, gosh, doesn't everyone? Or they learn a tiny bit of information (".Net can be used to do things kind of like this") and refuse to consider anything else because that would reveal the tinyness of their knowledge.
    Though it's not clear to me from your description whether applets are the best solution either. Why does he need a web site at all for this? What will the application do? Why not use C++ or Flash/Actionscript, for that matter?

  • I am trying to use an education program that needs Java applets to install and use and it will not use Safari. When I download IE from the web it will not install. How can I get a browser that will work on my MacAir for travel use of this program?

    I am trying to use and education program that needs Java applets and it will not run on Safari. IE will not install from the web. How do I get a browser that will work to install so I can use this program when I travel.

    Try using FireFox. IE will only run on a Mac if you run Windows on the Mac.
    Windows on Intel Macs
    There are presently several alternatives for running Windows on Intel Macs.
    Install the Apple Boot Camp software.  Purchase Windows 7 or Windows 8.  Follow instructions in the Boot Camp documentation on installation of Boot Camp, creating Driver CD, and installing Windows.  Boot Camp enables you to boot the computer into OS X or Windows.
    Parallels Desktop for Mac and Windows XP, Vista Business, Vista Ultimate, or Windows 7.  Parallels is software virtualization that enables running Windows concurrently with OS X.
    VM Fusion and Windows XP, Vista Business, Vista Ultimate, or Windows 7.  VM Fusion is software virtualization that enables running Windows concurrently with OS X.
    CrossOver which enables running many Windows applications without having to install Windows.  The Windows applications can run concurrently with OS X.
    VirtualBox is a new Open Source freeware virtual machine such as VM Fusion and Parallels that was developed by Solaris.  It is not as fully developed for the Mac as Parallels and VM Fusion.
    Note that Parallels and VM Fusion can also run other operating systems such as Linux, Unix, OS/2, Solaris, etc.  There are performance differences between dual-boot systems and virtualization.  The latter tend to be a little slower (not much) and do not provide the video performance of the dual-boot system. See MacTech.com's Virtualization Benchmarking for comparisons of Boot Camp, Parallels, and VM Fusion. A more recent comparison of Parallels, VM Fusion, and Virtual Box is found at Virtualization Benchmarks- Parallels 10 vs. Fusion 7 vs. VirtualBox. Boot Camp is only available with Leopard and later. Except for Crossover and a couple of similar alternatives like DarWine you must have a valid installer disc for Windows.
    You must also have an internal optical drive for installing Windows. Windows cannot be installed from an external optical drive.

  • On certain web sites(with java applets embedded or rich content),sometimes browser hotkeys are beeing used with other functionality (eg.: youtube uses ctrl + tab for sliding between player controls).How can I prevent this?

    On certain web sites(with java applets embedded or rich content),sometimes browser hotkeys are beeing used with other functionality (eg.: youtube uses ctrl + tab for sliding between player controls).How can I prevent this ?

    Thanks for posting this!
    I would only mention that your definition is incomplete for this -
    Contextual selector A type of Style Sheet Selector that
    and that it's most often referred to now as a Descendent selector, not a contextual selector.  It's basically the same as the Compound selector that you have already defined....

  • When using Java Wizard with Firefox 3.6.23 on a Mac OS X 10.6.8 it keep getting an error message: "The Java Wizard cannot run. Please configure your browser to allow Java applets to access the filesystem." Have NO idea how to fix this problem.

    When trying to upload files I received the following error: "The Java Wizard cannot run. Please configure your browser to allow Java applets to access the filesystem."

    If the problem is with a site that is hosted using MOVEit DMZ by Ipswitch, please notify the site owner of the issue and ask them to apply the patch that is available on the support site to resolve the issue.
    This is a better resolution than downgrading your version of Java that was updated due to security issues.

  • How to update content of a file on server using a Java Applet?

    Hi,
    I'm new to Java, and I have a task now to overwrite a text file on a server using an applet. I have written a piece of code which compiles but doesn't work. Can you please take a look at the code or give me another way to do it?
    Thanks.
    Code:
    import java.applet.Applet;
    import java.io.*;
    import java.net.*;
    public class test2 extends Applet{
    public void init() {
    StringBuffer buf = new StringBuffer();
    try {
         String output = "this is some string";
         URL aUrl = new URL (getCodeBase().toString() + "test.txt");
         System.out.println(aUrl);
         URLConnection con = aUrl.openConnection();
         con.setDoOutput(true);
         PrintWriter out = new PrintWriter( new BufferedWriter( new OutputStreamWriter(con.getOutputStream())));
         out.println(output);
         out.close();
    catch (MalformedURLException mue) {
         System.out.println("improper url");
         mue.printStackTrace();
    catch (IOException e) {
         System.out.println("io exception");
         e.printStackTrace();
    }

    Ram.ViSolve wrote:
    869975 wrote:
    Thanks. I knew there would be a security issue, but I do not have sufficient knowledge to get around it. If you have a reference how to configure a server please post it here.You need to create Signed Applet. Because normally applets have some restriction to access the files in the client machine. Signed applets overrides the restriction.
    To know more, Read [url http://192.9.162.55/developer/onlineTraining/Programming/JDCBook/signed.html]Signed Applet
    No. Our OP wants to write to the server, not to the client! And to achieve this from an applet, you don't need it signed, iff the server is the machine from where the applet was downloaded in the first place. You only need to use a mechanism that allows you to write to servers, which HTTP is not. FTP, on the other hand, if setup properly can do it. So instead of trying to write using an HttpURLConnection (OP's attempt), you would use an FTP client library. FTP here is just an example and probably not the best way. Another option is to use some servlet or PHP or ASP on the server side and the applet will sumbmit the changes to that code on the server, which in turn will write to the file. The idea is that you need some 'partner code' on the server, be it the FTP server or the servlet/PHP/ASP code. None of this requires the applet to be signed.

Maybe you are looking for

  • EFT and payment advice

    Hi, We are planning to implement Electronic Funds Transfer (EFT) and send the payment advices to suppliers via E-mail or FAX. Is there any one who have implemented that and can shed some light to me. Is the solution possible with in Oracle Financials

  • The best way to manage multiple iPhones

    Hi, We currently own three iPhones, my wife's, my daughter's and mine and we are all using basically the same apple ID which is good for purchased apps since I have to buy it once and they automatically show on all devices, the issue is with free and

  • HELP! Restore password lost

    I have an iphone 5 and went to update to the 8 IOS and had errors and issues. It seems to have updated now, but I lost ALL of my information on it. Since this is a work phone for my business it's VERY important that I restore it. I backed up the phon

  • My iphone 4s won't restore - internal error

    My iPhone 4s was syncing fine until last month.  It failed due to an "internal Error" in the phone.  After 4 hours of tech support with Apple and several reset to factory settings and removal and reinstallation of iTunes, it still failed.  I was then

  • Keynote hides .key file extension on save - feature or bug?

    I haven't been able to track anything down about this in the forum... I've created a new file in Keynote '09, and saved it with the standard .key extension. When I open the file, edit it, and "save" it, Keynote hides the extension. If I go to the fil