★ wanayoo — archive 1999 http://blogs.oracle.com/thejavatutorials/Nouvelle recherche | Portail wanayoo

Friday Mar 18, 2011

St Patrick's Day Release of Java Tutorial

We have recently released two updates of the Java Tutorial. The February 21st update was designed to coincide with the JDK7 Developer Preview Release. The tutorial was updated again on St Patrick's Day, March 17th.

The updated content for both releases includes the following features:

The updated tutorial is available as a download from The Java Tutorials front page.

We hope you enjoy the updated content!

-- Sharon Zakhour

Monday Nov 01, 2010

Java Tutorials Download is Available!

We are happy to report that the Java Tutorials download bundle is once again available. You can access it through the front page of the tutorial. Look for the Download link, inside the "Tutorial Resources" box, to the right.

We have also added another feature to this release that you may find useful, especially if you are new to the Java Tutorials. The Learning Paths page will point you towards the trails that are most relevant to your needs. Please let us know what you think! (While we can't respond to every email, we do read each one!)

-- Sharon Zakhour

Wednesday Oct 20, 2010

Update of the Java Tutorial

Several days ago, Oracle released Java Platform, Standard Edition 6 Update 22. To coincide with this release, we also published an update of The Java Tutorials.

This update includes:

  • The new Fork/Join page, part of the Concurrency lesson, describes how you can use the Fork/Join framework to take advantage of multiple processors. This feature is available now in the JDK 7 release available on java.net.
  • The JDBC Basics lesson has been completely revamped, including updated sample code that you can download, compile, and run – the code has been configured for Java DB and MySQL. See Getting Started for more information. Note that the rest of the JDBC tutorial is also being updated, so look for that in a future release.
  • Finally, a small, but notable, change is that the standalone JNDI tutorial, previously available on java.sun.com, has been moved to the Java SE documentation archive on download.oracle.com and many broken links in the tutorial have been fixed. The front page of the JNDI tutorial has been modified accordingly, and redirects are in place ensuring a seamless transition.

I know that many folks have been frustrated by the lack of a downloadable tutorial for the last several months. Rest assured we are working on it and hope to have a version available soon. We do apologize for the delay and are committed to providing a downloadable tutorial once again.

-- Sharon Zakhour

Wednesday Jul 07, 2010

New Release of Java Tutorial

The Java Tutorial has been migrated to its new home on download.oracle.com. You might want to bookmark the new location, however, redirects are in place. Any attempt to access the previous location at java.sun.com, is re-directed to the new location. We hope this will be a seamless transition for our many tutorial readers, but please let us know if you encounter any problems.

This migration of the tutorial also coincides with the JDK 6 Update 21 release.

The following updates are included in this release:

Note that it is not yet possible to download the July 7th, 2010 edition of the tutorial. We are working out some logistics, but it should be available for download in the next couple of weeks.

Thanks for your patience.

-- Sharon Zakhour

Tuesday Jun 15, 2010

Podcast on The Java Tutorial, A Short Course on the Basics, 4th Edition

As part of the Oracle Author Podcast Series, a podcast about the book, The Java Tutorials: A Short Course on the Basics, 4th Edition, has just been released. The fourth edition of the book consists of the core concepts from the online Java Tutorials. You can hear the podcast through the Oracle Author Podcasts website.

Check it out!

Thursday Feb 18, 2010

Getting Java Applets to Work on Mac OS

Are you having trouble viewing some Java applets on a Mac? Got next generation Java Plug-in? The next generation Java Plug-in (introduced in Java SE 6 update 10), needs to be enabled in order to view applets that leverage features of this Java Plug-in. The next generation Java Plug-in is not enabled by default on Mac OS systems. So here are a few tips to enable the plug-in.
  • Upgrade to a 6u17 based Java update. This support page from Apple might be helpful.
  • Open the Java Preferences application and toggle setting to "Run applets: in their own process".
  • Restart your browser and try viewing the applet.
When using Firefox 3.5 and above, in some cases the Java Preferences setting does not fully disable the default MRJPlugin and fully enable the next generation Java Plug-in. If after the performing the above steps you still have problems viewing some applets, you will need to go to the guts of the problem. :-)

Perform the following steps to disable the default MRJPlugin:

  • Go to the /Applications/Firefox.app/Contents/MacOS/plugins directory.
  • Move the following files to a temp directory or another location:
    • JavaEmbeddedPlugin.bundle
    • MRJPlugin.plugin
  • Restart your browser.
  • To check which plug-in is being used by your browser, view the about:plugins URL. An entry titled "JavaPlugin2_NPAPI.plugin" indicates that the next generation Java Plug-in is enabled in your browser.

You can now enjoy Java applets on MacOS!

- Sowmya

Tuesday Jan 12, 2010

Java Tutorial Update

We have just pushed an updated version of the Java Tutorial to the web to coincide with the release of Java 6 Update 18.

This update to the tutorial features some additions and an update to the Deployment trail:

  • Developing Draggable Applets – a new topic describing how to create an applet that can be dragged outside of a browser and dynamically converted into a Java Web Start application.
  • Sending Messages to Other Applets has been rewritten.
  • Deploying Without the Codebase Attribute – a new section describing how to use functions in the Deployment Toolkit script to develop and test Java Web Start applications without specifying the codebase attribute in the application's Java Network Launch Protocol (JNLP) file. The ability to deploy and launch Java Web Start applications without specifying the codebase attribute is introduced in the Java SE 6 Update 18 release.
Also, we previously reported that some of the Swing examples would not open under NetBeans 6.5 or later, unless the project.xml file was patched. This problem is fixed.

Thanks, as always, for your feedback.

- Sharon Zakhour

Wednesday Nov 25, 2009

Java Applets Quiz

Do you enjoy quizzes? Take a minute to answer this quiz about Java applets. Java Applets Quiz

Don't worry you wont be graded. ;-)

-- Sowmya Kannan

Tuesday Nov 24, 2009

Getting Applets To Talk To Each Other

Do you have more than one applet on a web page? Do you want the applets to share water cooler gossip? Ahem..ahem.. On a more serious note, do you want one applet to invoke methods or set variables of another applet?

Long long ago, you may have accomplished applet communication with the use of static variables. This method of sharing applet data is not fool proof. Different applets may run in different instances of the Java Virtual Machine software. This makes it impossible for an applet to see static variables set by another applet.

An applet can communicate with other applets by using JavaScript functions in the parent web page. JavaScript functions enable communication between applets by receiving messages from one applet and invoking methods of other applets. See the following topics for more information about the interaction between Java code and JavaScript code:

You should avoid using the following mechanisms to find other applets and share data between applets:

  • Avoid using static variables to share data between applets.
  • Do not use the getApplet and getApplets methods of the AppletContext class to find other applets. These methods only find applets that are running in the same instance of the Java Runtime Environment software.

Applets must originate from the same directory on the server in order to communicate with each other.

Consider two applets called Sender and Receiver. When a user clicks the button to increment the counter, the Sender applet invokes a JavaScript function to send a request to the Receiver applet. Upon receiving the request, the Receiver applet increments a counter variable and displays the value of the variable.

To enable communication with another applet, obtain a reference to an instance of the netscape.javascript.JSObject class. Use this instance to invoke JavaScript functions. The Sender applet uses an instance of the netscape.javascript.JSObject class to invoke a JavaScript function called sendMsgToIncrementCounter.

try {
    JSObject window = JSObject.getWindow(this);
    window.eval("sendMsgToIncrementCounter()");
} catch (JSException jse) {
    ...
}

Note: To compile Java code that has a reference to classes in the netscape.javascript package, include <your JDK path>/jre/lib/plugin.jar in your classpath. At runtime, the Java Plug-in software automatically makes these classes available to applets.

Write the JavaScript function that will receive requests from one applet and invoke methods of another applet on the web page. The sendMsgToIncrementCounter JavaScript function invokes the Receiver applet's incrementCounter method.

<script>
    function sendMsgToIncrementCounter() {            
        receiver.incrementCounter();
    }
<script>

Note that the JavaScript code uses the name receiver to obtain a reference to the Receiver applet on the web page. This name should be the same as the value of the id attribute that is specified when you deploy the Receiver applet.

The Receiver applet's incrementCounter method is shown next.

public void incrementCounter() {
    ctr++;
    String text = " Current Value Of Counter: " + (new Integer(ctr)).toString();
    ctrLbl.setText(text);
}

Deploy the applets on the web page as shown in the following code snippet. You can view the Sender and Receiver applets and associated JavaScript code in AppletPage.html in this example's source code..

<!-- Sender Applet -->
<script src="/old?u=http%3A%2F%2Fwww.java.com%2Fjs%2FdeployJava.js&y=1999"></script>
<script> 
    var attributes = { code:'Sender.class',
        archive:'examples/dist/applet_SenderReceiver/applet_SenderReceiver.jar',  width:300, height:50} ;
    var parameters = {};
    deployJava.runApplet(attributes, parameters, '1.6');
</script>

<!-- Receiver Applet -->
<script> 
    var attributes = { id:'receiver', code:'Receiver.class',
        archive:'examples/dist/applet_SenderReceiver/applet_SenderReceiver.jar',  width:300, height:50} ;
    var parameters = {};
    deployJava.runApplet(attributes, parameters, '1.6');

</script>

Download source code for the Sender Receiver Applets example to experiment further.

As always, please don't hesitate to send us your feedback!

-- Sowmya Kannan

Tuesday Nov 17, 2009

Reader Poll: Who Wants Screencasts?

Hi everyone,

We're running a reader poll over on the JavaFX blog. We'd like to know your thoughts on screencasting vs. written tutorials. Please take a minute to visit that page and leave a comment. We greatly value your opinion!

- Scott Hommel

Friday Nov 13, 2009

Re-spin Your Desktop Application Into A Java Web Start Application

Do you have a desktop application that you'd like to distribute to a wider audience? How about monetizing your application by showcasing it on the Java Store?

Check out the screencast for valuable information about how to accomplish this.

Download the source code for the Menu Application shown in the screencast.

See the following resources for more information:

We would be delighted to hear feedback about the screencast!

-- Sowmya Kannan

Wednesday Nov 11, 2009

NetBeans and the Swing Examples in The Java Tutorial

Several years ago we converted the 100+ examples in the Swing Tutorial to NetBeans projects. We have received several reports of people having trouble opening those NetBeans projects and we have learned that, as of NetBeans 6.5, a tag is now required in the project.xml file, even if that tag is empty.

We are working on updating those examples but, until that happens, you have to manually add the following tag to your project.xml file, before the </data> tag:

<test-roots/>

For example, the corrected project.xml file for the TableFilterDemoProject example would read:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
    <type>org.netbeans.modules.java.j2seproject</type>
    <configuration>
        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
            <name>TableFilterDemo</name>
            <minimum-ant-version>1.6.5</minimum-ant-version>
            <source-roots>
                <root id="src.dir"/>
            </source-roots>
            <test-roots/> <!-- ADDED -->
        </data>
    </configuration>
</project>

Thanks for your patience until we fix this problem and thanks, as always, for reading the Java Tutorials.

-- Sharon Zakhour

Monday Oct 12, 2009

Update -- Mixing Heavyweight and Lightweight Components article

On Sept 23rd, I posted about a new article that describes how you can easily mix heavyweight and lightweight components in 6u12 and JDK7. The calculator example included with the article tickled a known bug on some systems.

The example has now been updated with the recommended workaround. Also, the text of the article calls out the workaround (see the first bullet under the Requirements section).

Thanks, as always, for your feedback!

-- Sharon Zakhour

Wednesday Sep 23, 2009

Mixing Heavyweight and Lightweight Components

Have you ever tried to put a heavyweight component, such as a java.awt.Button or a java.awt.Label, in a window that has a lightweight component (for example, a javax.swing.JMenu)? Where the menu overlaps the button (or label), the lightweight menu appears underneath the heavyweight component. But, as of 6u12 and JDK7 build 19, this now "just works." For more information, see the new article Mixing Heavyweight and Lightweight Components.

- Sharon Zakhour

About

thejavatutorials

Search
Recent Posts
Top Tags
Categories
Archives
« May 2011
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
    
       
Today
Bookmarks
Menu
Feeds