| How to download metafiles using a signed applet |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- Project confusionOkay I'm not exactly sure what I'm supposed to do. I know I should
create a file that creates an abstract tree but I can't figure out
exactly what the other programs do and how I should use them to
implement an abstract tree. So if someone could please shed some light
as to what direction I should be going in it would be a lot of help.
The website as to where the assignment is located is as follows:
http://www.cs.uiowa.edu/~slonnegr/plc/. The pdf that describes the
homework is under the link Parse Homework under the Homework header.
Agains thanks for the help.
- 3
- JList Font BugConsider this SSCCE. If you take out the comment on the setFont
statement, it stop working -- displaying a blank screen in W2K/JDK 1.0
Why. It fails even when I set it to the default Dialog, 12 , BOLD.
// sample use of jList
// The code is quite different from AWT List.
import java.awt.Color;
import java.awt.Font;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.ListSelectionModel;
public class TestJList
{
/**
* Debugging harness for a Frame
*
* @param args command line arguments are ignored.
*/
public static void main ( String args [] )
{
final JFrame frame = new JFrame();
final JList flavour = new JList( new String[] { "strawberry",
"chocolate", "vanilla"} );
flavour.setForeground( Color.BLUE );
flavour.setBackground( Color.WHITE );
System.out.println( flavour.getFont() );
// flavour.setFont( new Font( "Dialog", 12, Font.BOLD ));
// setting the selection
flavour.setSelectedIndex( 0 );
flavour.setSelectedValue ( "chocolate", false /* scroll */ );
// allowing multiple selections, the default.
flavour.setSelectionMode(
ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
// set multiple selections
flavour.setSelectedIndices( new int[] { 0, 2} );
// there is no setSelectedValues method
flavour.addListSelectionListener( new ListSelectionListener()
{
/**
* Called whenever the
value of the selection changes.
* @param e the event that
characterizes the change.
*/
public void valueChanged(
ListSelectionEvent e)
{
// detecting individual
selection
System.out.println(
"--selection--" );
// will be null if there
are none or multiple selections.
String choice = (String)
flavour.getSelectedValue();
System.out.println(
choice );
// will be -1 if there
aare none or muliple selections.
int which =
flavour.getSelectedIndex();
System.out.println(
which );
// detecting multiple
selections
System.out.println(
"--multiples--" );
Object[] choices =
flavour.getSelectedValues();
for ( Object aChoice :
choices )
{
System.out.println(
aChoice );
}
int[] indexes =
flavour.getSelectedIndices();
for ( int index :
indexes )
{
System.out.println(
index );
}
}
});
frame.add( flavour );
frame.setSize( 100, 100 );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.validate();
frame.setVisible( true );
} // end main
}
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
- 3
- M'I`5'Persecu tion ' how an d w hy di d it s tart?-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-= how and why did it start?. -=
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
The harassment didn't. start by itself, so someone must have been there at
the outset to give it a firm push and set the. "animals" after me. It looks
as if I was set up in June 1990, and the timing indicates. someone from
university was. responsible.
>One thing which has. been missing from this discussion is this simple
>prognosis: that. maybe he is right and that, despite his admitted
>mental condition, there really is a campaign against him. organised by
>now-influential ex-students. of his university.
In May or June 1990, Alan Freeman. on Radio 1 read out a letter from someone
who had known me for a few years, who wrote of the. one who "wore out his
welcome with random precision" (from the Pink. Floyd song). Freeman went on
to say to the writer "that's a hell of a. letter you wrote there". The
indication is strongly. that people I had parted from soon before nursed a
grudge against me and were trying. to cause trouble for me.
The suggestion is that Freeman might have shown the. letter to other people,
and things. could have snowballed from there. Right from the start the real
source (security services. presumed) didn't announce themselves as the
origin, but let the. "talkers", the radio DJs, believe that they were the
originators.. Think about it; if you announce, "we're MI5 and we have a
campaign against. this bloke" then people might not go along with it; but if
you say, "everyone. else is getting at this bloke because he 'deserves' it"
then people will join in with. fewer qualms.
>Why would "they" wish to assassinate. your character?
It's the. classic case of hitting a cripple to prove you're stronger. Why
would the security services expend hundreds of thousands of. pounds and more
than six years of. manpower to try to kill a British citizen? Because they
are motivated by people who knew. me at university and feel personal
animosity; because they. knew me to be emotionally weak, and it is in the
nature of bullies to prey on those. known to be weak; and because they can
rely on the complicity of the establishment, which the security. services
manipulate and derive funding. from. This is England's biggest humiliation
today, and the British security services. are intent on preventing their
humiliation becoming reality. by continuing their campaign of attempted
murder to suppress. the truth from becoming public.
1032
- 3
- DER decoding from x.509 v3 certificateI need to read the extension field of a x.509 v3 certificate.
I use the java method getExtensionValue().
The method return an array of bytes DER-encoded.
I want to read it as a String and print it on screen. So I have to decode
the array and convert it.
I try a lot of way to do that but I never obtain good result.
Someone can help me?
Then, the DER encoding is equal to Base64 encoding or not?
Thanks
- 4
- Problem with JNI on LinuxI am having a problem getting JNI to work on Linux. I think it is with
how I am creating the shared object file. I am using Java 1.5.0_8 and
Redhat Enterprise version 3 release 4. I have not used JNI before so I
did a web search and found a simple example that I am trying to get to
work. The problem is that I am getting an UnsatisfiedLinkError. It looks
like there are many flavors of this error and I can get at least three
of them :(
My Java program is:
class FirstJNI
{
public native void displayHelloWorld();
public native void displayOther();
public native String getLine(String prompt);
static {
System.out.println("in static");
System.loadLibrary("FirstJNI");
}
public static void main(String[] args)
{
System.out.println("entered main");
System.out.println("creating new FirstJNI");
FirstJNI jN=new FirstJNI();
jN.displayHelloWorld();
jN.displayOther();
String input = jN.getLine("Enter Some Thing ");
System.out.println("You Entered " + input);
}
}
and my c library is:
#include "FirstJNI.h"
#include <stdio.h>
JNIEXPORT void JNICALL
Java_FirstJNI_displayHelloWorld(JNIEnv *env, jobject obj)
{
printf("Hello world! \n");
return;
}
JNIEXPORT void JNICALL
Java_FirstJNI_displayOther(JNIEnv *env, jobject obj)
{
printf("Hello world! This is Other Function.\n");
}
JNIEXPORT jstring JNICALL
Java_FirstJNI_getLine(JNIEnv *env, jobject obj, jstring enter)
{
char buf[128];
const char *str = (*env)->GetStringUTFChars(env, enter, 0);
printf("%s", str);
(*env)->ReleaseStringUTFChars(env, enter, str);
scanf("%s", buf);
return (*env)->NewStringUTF(env, buf);
}
I am building them with the following commands:
/usr/java/jdk1.5.0_08/bin/javac FirstJNI.java
/usr/java/jdk1.5.0_08/bin/javah -jni FirstJNI
gcc -O2 -I/usr/java/jdk1.5.0_08/include
-I/usr/java/jdk1.5.0_08/include/linux -fno-strict-aliasing -fPIC
-fno-omit-frame-pointer -W -Wall -Wno-unused -Wno-parentheses -c FirstJNI.c
gcc -Wl,-soname=libFirstJNI.so -shared-libgcc -lc -shared -o
libFirstJNI.so FirstJNI.o
If I then try and run it (after setting my LD_LIBRARY_PATH) I get:
[hsr@palain8 jni]$ /usr/java/jdk1.5.0_08/bin/java FirstJNI
in static
Exception in thread "main" java.lang.UnsatisfiedLinkError:
/users/hsr/apache-tomcat-4.1.32/webapps/perf/jni/libFirstJNI.so:
/users/hsr/apache-tomcat-4.1.32/webapps/perf/jni/libFirstJNI.so: cannot
open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1676)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:993)
at FirstJNI.<clinit>(FirstJNI.java:9)
This is strange since it is giving me a fully qualified path and if I do
an ls of that path the file is there. So, just for fun I removed the
file, tried again and got:
[hsr@palain8 jni]$ /usr/java/jdk1.5.0_08/bin/java FirstJNI
in static
Exception in thread "main" java.lang.UnsatisfiedLinkError: no FirstJNI
in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:993)
at FirstJNI.<clinit>(FirstJNI.java:9)
This indicates to me that in the first example it really knew the file
was there and that there was something else wrong. Next I went to the
demo directory of the java 1.5.0_8 install and grabbed an .so file out
of there and copied t to my directory. Now I get:
[hsr@palain8 jni]$ /usr/java/jdk1.5.0_08/bin/java FirstJNI
in static
entered main
creating new FirstJNI
Exception in thread "main" java.lang.UnsatisfiedLinkError: displayHelloWorld
at FirstJNI.displayHelloWorld(Native Method)
at FirstJNI.main(FirstJNI.java:20)
This is exactly what I would expect and the fact that this time it found
the .so indicates to me that it has nothing to do with my misnaming the
methods. So, I can only conclude that it is seeing my .so but not
recognizing it as valid which indicates that I am not linking it correctly.
After this long winded posting does anyone have any words of wisdom or
suggestions?
Thanks
Howard
- 4
- executeQuery() doesn't time out, blocks indefinitely on network failureI am developing an application that must gracefully recover from
network failures, however I noticed that executeQuery() never returns
or throws an exception for a time out when the network goes down (which
I simulated by unplugging my ethernet cable). The TCP connections of
all my pooled database connections remain open and dead even after
plugging the cable back in. Calling queryTimeout() explicitly has no
effect--executeQuery() stays blocked on network IO forever. Is there a
way to time out executeQuery(), or some way to stop it from never
returning?
I'm using version 10.2.0.1.0 of Oracle's JDBC driver with the 1.5 JDK.
Code:
import java.util.*;
import java.sql.*;
import oracle.jdbc.pool.*;
public class Oracle
{
private OracleDataSource oracleDataSource;
public Oracle() throws Exception
{
oracleDataSource = new OracleDataSource();
oracleDataSource.setURL("jdbc:oracle:oci:@dev");
oracleDataSource.setUser("dbp");
oracleDataSource.setPassword("dbp");
oracleDataSource.setConnectionCachingEnabled(true);
}
public void validate()
{
Connection c = null;
Statement s = null;
ResultSet r = null;
try
{
System.err.printf("connecting...\n");
c = oracleDataSource.getConnection();
System.err.printf("connected\n");
s = c.createStatement();
s.setQueryTimeout(1);
for (;;) {
System.err.printf("executing...\n");
r = s.executeQuery("select 1 from dual");
System.err.printf("executed\n");
r.close();
try { Thread.sleep(1000); } catch (Exception e)
{ }
}
}
catch (Exception e)
{
e.printStackTrace();
try { r.close(); } catch (Exception ee) { }
try { s.close(); } catch (Exception ee) { }
try { c.close(); } catch (Exception ee) { }
}
}
public static void main(String[] args)
{
Oracle oracle = null;
try
{
oracle = new Oracle();
oracle.validate();
}
catch (Exception e)
{
e.printStackTrace();
System.exit(1);
}
}
}
Output:
> javac -cp ./ojdbc.jar Oracle.java && java -cp .:./ojdbc.jar Oracle
connecting...
connected
executing...
executed
(ethernet cable unplugged...)
executing...
(i waited a very long time, and nothing happened...)
- 10
- Treasure Trooper what you do here is you complete simple surveys and offers, some
require a credit card, but i just do all the free ones :D
its easy to do, you just register and do the offers, then click the
"done" button when you have completed it to what the instructions say,
here is the website if you want to check it out
www.treasuretrooper.com/111524 (copy and paste into browser
this is how the payment works: say in june you made 60$, then on the
15th of next month, so on july 15th you would get your money. they send
a check in the mail so yes, you have to provide your correct address,
not a fake one (dont worry they dont spam you with shit) and you will
get a check in the mail from them and you can cash it like any other
check.
so far, i have been doing this thing for 2 months and i have been payed
$156.50 total. its easy money and only takes about half an hour a day
if your really keen on it, but usually 10 minutes is fine. on their
forums i ha ve heard that people are making like $200+ i hope i can get
that much in the future. im pretty close.
once again, if you are interested in signing up, here is where you go:
www.treasuretrooper.com/111524 (copy and paste into your browser)
- 10
- GUI and command lineHello,
I need to connect my GUI program with a terminal in Linux (command
line). The task is to input inside a textField the command to exectue as
for exemple: "ls -al" or "gcc whatever.c -o whatever" but everything
must be done by a GUI program.
How can I call the terminal or execute these commands?
thanks,
Marcelo
- 12
- efficient way to replace char in StringBufferI normally use strings. Just starting to use StringBuffer.
How can I do the following better? (Replace <cr> and <lf>
with <space>)
String s = DynamicPanel.dynamicCmdArea.getText(0, len);
StringBuffer ss = new StringBuffer(s);
int j = -1;
while ((j = ss.indexOf("\n")) != -1)
ss.setCharAt(j, ' ');
while ((j = ss.indexOf("\r")) != -1)
ss.setCharAt(j, ' ');
- 12
- TextArea and imagesHi,
I am working on a chat applet, and I would like it to show an image
next to some text received from the server. I have looked everywhere I
can think of for a similar piece of code, but I haven't succeeded yet.
I use a TextArea for inserting the text received but I don't know how
to insert the image into the TextArea next to the text. Is there any
way to do this?
I also want some of the text and the image to be hyperlinked to other
web pages for loading upon cliking. I think I have found how to do
this, although I haven't tried it yet.
Any help specially with the first question will be appreciated.
Thank you
Miguel
- 13
- Reporting tool to be used with swingHello All,
I'm looking for a report generation tool to be used in a swing project
I'm working. The resports will involve very complex charts and graphs.
Kindly suggest tools which will meet these requirements.
Thanks and Regards
Chanchal
- 13
- SinotticoDovrei sviluppare un sinottico in java qualche idea non so da dove partire
Grazie
- 15
- How to use an unsigned number in Java?People, is there a library that allow me to use unsigned numbers? I need
this to implement a protocol but I don't want to have to keep masking a
long number.
- 15
- RTF parser componentHi all.
i want component which is sperating text frm rtf text.rtf text contains
images and some embedded objects which i want to seperate.
Does anyone know it.
Please help me.
- 16
- eclipseAndreas Kohn wrote:
>Works for me on FreeBSD/i386 6.0-CURRENT. I applied attached build to
>have eclipse build with mozilla-devel instead of the default mozilla.
>
>
I've combined this fix with the one Bruno sent, as well as a few other
random cleanups. Here's an updated package:
http://www.varju.ca/alex/freebsd/eclipse-devel-3.1m6-3.tgz
The libswt-mozilla library is building now, but I don't think it's
working correctly on my system. I'm not positive, but I think the Help
system uses it .. if I try to go to Help Contents, nothing happens.
(This is better than before the plugin was built, as then it created a
mozilla process that spun forever).
This patch is still missing Motif support. I've just flagged this as
broken, as I don't actually expect to track this down myself. My i386
system is far too slow to do test builds on, and it doesn't like there
are linux x86_64 motif build files to base an amd64 build on.
>One strange thing: At one build stage, it looked like it would build
>gtk64 support things, is this to be expected on i386?
>
>
It's possible that I've messed something up there, but it's also
possible that Eclipse builds more than it actually needs. What exactly
are you seeing?
Alex.
|
| Author |
Message |
Brian

|
Posted: 2007-10-9 5:34:00 |
Top |
java-programmer, How to download metafiles using a signed applet
I want an applet which, once launched, downloads 3 metafiles (files
that it will need later on to work properly) and proceeds into a
processing phase only if the files have been successfully fetched.
So far I do not have a solution for requesting these files and writing
them locally.
Am I following the right track with URL and HttpURLConnection, or
should I be looking into packages like the Apache Jakarta project?
Is there possibly a more straightforward way to instruct the JRE to go
get file "http://www.foo.com/dist/localdata.dat" and put it at
location "C:\localdata.dat" ?
Is there possibly some correlation between the domain mentioned in my
signing certificate and the domain from which I download any
particular file?
Thanks for any ideas,
Brian Herbert Withun
|
| |
|
| |
 |
Andrew Thompson

|
Posted: 2007-10-9 7:48:00 |
Top |
java-programmer >> How to download metafiles using a signed applet
On Oct 9, 7:34 am, Brian <email***@***.com> wrote:
> I want an applet which, once launched, downloads 3 metafiles
Easy enough done. If they are coming from the same
server, it can be done in a sandboxed applet. A
trusted applet could obtain them from any server
on which they available as a publicly fetchable
resource (assuming the server does not specifically
refuse connections to whatever UA the URLConnection
identifies itself as).
>..(files
> that it will need later on to work properly) and proceeds into a
> processing phase only if the files have been successfully fetched.
>
> So far I do not have a solution for requesting these files
There are a number of ways to do it.
>...and writing them locally.
Why do you want to do that?
Andrew T.
|
| |
|
| |
 |
Roedy Green

|
Posted: 2007-10-9 11:13:00 |
Top |
java-programmer >> How to download metafiles using a signed applet
On Mon, 08 Oct 2007 21:34:06 -0000, Brian <email***@***.com> wrote,
quoted or indirectly quoted someone who said :
>So far I do not have a solution for requesting these files and writing
>them locally.
Have a look at the code for Download. It does all that. It is part
of the package at http://mindprod.com/jgloss/filetransfer.html
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
|
| |
|
| |
 |
Brian

|
Posted: 2007-10-9 23:04:00 |
Top |
java-programmer >> How to download metafiles using a signed applet
> Easy enough done. If they are coming from the same
> server, it can be done in a sandboxed applet. A
> trusted applet could obtain them from any server
> on which they available as a publicly fetchable
> resource (assuming the server does not specifically
> refuse connections to whatever UA the URLConnection
> identifies itself as).
>
I'll have a signed applet hosted on a partner's site (not the same
company as identified in the signing cert) The files will be coming
from the same server as the applet, though.
That being said, what is a reasonable *way* to retrieve the files?
I'm new to Java and I'm looking for some best-practices. I have read
about HttpURLConnection and have looked briefly at Jakarta.
What's the equivalent to
C:\XCOPY www.domain.com/dist/file.dat C:\LOCALDATA\
>
> >...and writing them locally.
>
> Why do you want to do that?
One of the files is a java-compatible Windows DLL that automotive
repair shops will need when using this applet to interface with their
vehicle VCI. That DLL needs to go into the Windows directory.
..or will Windows LoadLibrary find a DLL within the sandbox?
Brian Herbert Withun
|
| |
|
| |
 |
Andrew Thompson

|
Posted: 2007-10-10 0:43:00 |
Top |
java-programmer >> How to download metafiles using a signed applet
Brian wrote:
(DLL+metafile applet)
..
>I'll have a signed applet hosted on a partner's site (not the same
>company as identified in the signing cert) The files will be coming
>from the same server as the applet, though.
>
>That being said, what is a reasonable *way* to retrieve the files?
Retrieving them - InputStream. That might sound like a
dumb answer, but to make it more specific and less
dumb, I will add, to use..
a) for a resource available 'loose' on the server -
URL.openStream() for that InputStream
b) for a resource inside a jar file on the applet(/application)'s
classpath, use Class.getResource() for that URL, then see a).
The other side to your question is either using,
or storing and using them. ..
>..classpath, Class.getResource(name) for an URL, then a)..
>I'm new to Java and I'm looking for some best-practices. I have read
>about HttpURLConnection and have looked briefly at Jakarta.
It can be done with HttpURLConnection, but now I
check the JavaDocs, I realise it has a lot of cruft
(over URL) not needed for simply gettting an input
stream.
>What's the equivalent to
>
>C:\XCOPY www.domain.com/dist/file.dat C:\LOCALDATA\
(checks) XCOPY Copies files and directory trees.
>> >...and writing them locally.
I'll return to that later (if needed).
>> Why do you want to do that?
>
>One of the files is a java-compatible Windows DLL that automotive
>repair shops will need when using this applet to interface with their
>vehicle VCI. That DLL needs to go into the Windows directory.
>
>..or will Windows LoadLibrary find a DLL within the sandbox?
Hmm.. OK.
Not in an applet, it must be located in the 'Win' directory
for the applet to use it. *But* a web start based (and
sandboxed) applet or application can use DLLs that are
identified as nativelib's in the launch file (put on the
classpath). The only issue with using a sandboxed JWS
app. remains these metafiles.
Most well behaving DLLs that use external files expect
them to be in the 'same directory' so these could
(find and) use any metafiles supplied at the 'root' of
an archive also on the classpath of the JWS app.
BTW. I just realised this was the first time I'd
mentioned Java web start (JWS) in this thread, so
in case you are unfamiliar with it, check here for
some examples. <http://www.physci.org/jws/>
I am hoping you will abandon the idea of doing this
as an applet. That will be very problematic.
--
Andrew Thompson
http://www.athompson.info/andrew/
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200710/1
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Making a soundcard objectI have this idea of making a modem, that requires the soundcard to act
as my A/D and D/A, and in the middle will be my attempts at DSP. I
came up with this object, and it seems to test OK, but I could use
some constructive criticism, as I am definately at the OO 101 stage.
Merry Christmas, and a Happy New Years soon!
/**
* SoundCard.java
*
* @version 1.0, 1 December 2007
* @author Steve Sampson, K5OKC
*
* Public Domain (p) December 2007
*/
package modem;
import javax.sound.sampled.*;
import java.io.*;
public class SoundCard {
private static AudioFormat format;
private static TargetDataLine targetLine;
private static SourceDataLine sourceLine;
private static AudioInputStream sound;
public void SoundCard() {
}
/*
* Initialize Sound Card
*/
public boolean initPCM(double dblSampleRate) {
/*
* Encoding,
* Sample Rate (float),
* Sample Size (In Bits),
* Channels,
* Frame Size,
* Frame Rate (float),
* BigEndian (Boolean)
*/
format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
(float)dblSampleRate,
16,
1,
2,
(float)dblSampleRate,
false);
DataLine.Info targetInfo = new
DataLine.Info(TargetDataLine.class, format);
DataLine.Info sourceInfo = new
DataLine.Info(SourceDataLine.class, format);
try {
/*
* A source data line is written to
*/
sourceLine =
(SourceDataLine)AudioSystem.getLine(sourceInfo);
sourceLine.open(format); // Typical buffer size is same
as samplerate in bytes
sourceLine.start();
/*
* A target data line is read from
*/
targetLine =
(TargetDataLine)AudioSystem.getLine(targetInfo);
targetLine.open(format); // Typical buffer size is same
as samplerate in bytes
targetLine.start();
}
catch (LineUnavailableException e1) {
return false;
}
catch (SecurityException e2) {
return false;
}
catch (IllegalArgumentException e3) {
return false;
}
catch (IllegalStateException e4) {
return false;
}
if(!AudioSystem.isLineSupported(targetInfo)) {
return false;
}
sound = new AudioInputStream(targetLine);
return true;
}
/*
* Stop, flush, and close the soundcard interface
*/
public void closePCM() {
sourceLine.stop();
targetLine.stop();
sourceLine.flush();
targetLine.flush();
try {
sourceLine.close();
targetLine.close();
}
catch (SecurityException e)
{
}
}
/*
* Provide a block of Signed 16 bit PCM sound data
*/
public int getPCM(int[] intSampleArray) {
int intBytesRead;
byte[] byteData = new byte[intSampleArray.length * 2]; //
Convert count to bytes
/*
* Read bytes into array. This call will block if there aren't
* enough requested bytes.
*/
try {
intBytesRead = sound.read(byteData, 0, byteData.length);
} catch(IOException e) {
return -1;
}
/*
* This is designed for Little-Endian Intel machines
*/
for (int i = 0, j = 0; i < intBytesRead; i += 2, j++)
intSampleArray[j] = (byteData[i + 1] << 8) + byteData[i];
return intBytesRead / 2; // convert count to words
}
}
- 2
- basic question on Java in XPHello,
can someone please tell me how to ascertain what version (if any) of Java is
installed in a WinXP platform?
my friend needs some kind of Java module installed so that she can do a
tutorial for an online registration service.
any help would be appreciated.
Cynthia
- 3
- arrays of generic typesEclipse tells me that arrays of generic types are not legal, e.g.: it
won't allow the following:
QuadTree<MyNodeType> [] allQuadTrees;
Anyone know why this is the case?
- 4
- 9?. Steps To Improve Your FlyingThere are many things that you can do when you fly to make yourself a
safer and better pilot. Too many pilots get careless and stop doing
fundamental things that could save their lives. Here are some simple
things that you can do to improve your flying.
1. Use your rudder pedals.
It seems simple, right? Well, too many people neglect to get in the
good habit of using them. Use them during taxi, takeoff, climbs,
cruise, maneuvers, descents, and landing. Get the picture - Use them
all the time.
You can know exactly how much to use them during flight by looking at
the slip/skid indicator. That is the ball of the turn coordinator. As
long as the ball is centered between the lines, you are using the
right amount of rudder. If the ball is outside the lines, add rudder
in the direction that the ball is located.
For instance, if the ball is to the right, add right rudder. An easy
way to remember this is to "Step on the ball." Add enough pressure to
re-center the ball.
There are a lot of things happening when you are airborne. Correctly
using your rudder will make you a better pilot, keep your passengers
happy, and show your piloting professionalism (something you need to
have, even if you are not a professional pilot). Remember, step on the
ball.
2. Use Your Checklist
As you are flying, make sure that you use your checklist for each
portion of the flight. There are checklists for everything from
preflight to securing the airplane. Most airplanes have a checklist in
the owner's manual that you can use during your flights. Also, when
you learn to fly most flight schools have checklists that are
available for their students.
But checklists aren't put there to look pretty. Your job is to use
them. If you get in the habit of using one each flight, you will be
that much safer. It's not going to do you any good in your flight bag.
Even if you know the items by heart, still double check yourself
anyway.
Another thing, if you need to add something personal to your checklist
(like don't forget your sunglasses, or turn off your cell phone so the
battery won't run down as it searches for a signal in flight) do this
as well. As long as you have all the required items included, add any
that will help you personally during your flight.
3. G.U.M.P.S.
Whether you use G.U.M.P.S. as your landing checklist or not, get in
the habit of using a memorized checklist for your return to earth. In
a complex airplane, Gumps is; Gas, Undercarriage, Mixture, Propeller,
and Seatbelts. In a non-complex airplane, Gumps could be; Gas,
Undercarriage, Mixture, Power, and Seatbelts. Of course you don't
actually have to lower your gear on a fixed gear plane, but it is best
to remind yourself anyway. That way, when you do transfer to a
retractable gear airplane, you won't have to add anything to your
checklist. This also happens to be one of the most important checklist
items of the whole flight. So you will already be in the habit of
checking your landing gear when you get to the point where it really
matters.
4. Weight and Balance
Never ever forget to precisely calculate your weight and balance for
each flight. Too many people have gotten lazy and careless, and have
added extra weight in the form of passengers or cargo to their
airplanes, thinking that everything is ok. Isn't there room for error
- a little safety cushion, if you will - in the maximum useful load?
Why would you even want to know? If you take this attitude with your
flying, you are putting yourself and your passengers in a very
dangerous situation. Never operate out of the manufacturer's set
limitations for your airplane. They are there for a reason; to keep
you safe!
5. T.O.L.D.
Takeoff and Landing Data should be calculated for every flight as
well. Make sure that you are very familiar with all of the runways of
intended use and their lengths and widths. If it is not something that
you or your airplane can handle, don't make the flight. Don't get in
the habit of assuming that just because you are in a Cessna 172 that
every landing strip is suitable for your flight. Calculate your
takeoff and landing distances for each flight, taking into
consideration the density altitude and aircraft performance.
6. Appropriate Radio Calls
One flying safety item that can easily be performed is making sure
that you make your radio calls at the appropriate time. Whether you
are flying out of a towered or uncontrolled airport, be professional
with your radio calls. One common error is made at uncontrolled
airports, when after an airplane lands, the pilot calls clear of the
runway while part or all of the airplane is on the runway side of the
hold short line. This is dangerous! What if your airplane malfunctions
and you are stuck on the runway and another airplane thinks it's safe
to land? This is a hazardous situation that can easily be avoided. At
non-towered airports, it's better to not make any radio call at all,
than to make a dangerous one. Get it right!
7. Complete Runup
You have done a complete preflight inspection and are now ready to
takeoff. Make sure you do a complete engine runup as well. Check every
aircraft system while you are still on the ground before you get in
the air. Determine that all of your radios, comm and nav are
functioning. Check your vacuum and electric gyros. Check your flight
controls and your engine gauges. Know that when you take off, you are
as safe as you can be. There is no reason to rush through your runup.
8. Situational Awareness
Situational awareness is when you know exactly what is happening with
your flight and with what is going on around you. On the ground, you
need to make sure that you are aware of other airplanes that are
taxiing and using the runway. In the air, use the radio and your eyes
to know exactly where other airplanes are in relation to you as well
as their intentions. But situational awareness is not just limited to
knowing where other airplanes are. You also need to know exactly what
is happening with your airplane, the weather, airspace, the winds,
your location, what you would do in an emergency, etc. Regardless of
whether you are flying cross country or local, for fun or for
training, don't assume everything is alright. Know what is happening
around you.
9. Fly the plane from engine start to shutdown
When it comes to flying, make sure that you are maintaining vigilance
at all times in the airplane. Too many times pilots zone out at some
point in the flight. For many pilots, that time is before takeoff and
after landing. Make sure that even when you are on the ground, you are
flying the airplane. Keep a watchful eye out for other aircraft and
don't rely on the tower to separate ground traffic. Position your
flight controls so that you have the proper crosswind correction,
regardless of the wind speed. Even if the wind is calm, look at the
wind sock and taxi as if the wind is really blowing in the direction
indicated by the sock. Although you are on the ground, your control
surfaces are still somewhat effective. Treat them as if your safety
depends on their position.
9?. Have Fun
Even though it sounds simple, keep your flying fun. When you are in
the air, you are living a dream. Don't forget it!
http://cncarrental.cn/html/goodspeech/20060924/633.html
- 5
- Arrays - component type vs Element typeCan anyone explain to me the difference between an element type and a
component type?
In the java literature, arrays are said to have component types, whereas
collections from the Collections Framework are said to have an element
type.
http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html
states:
> The *component type* of an array may itself be an array type. The components of
> such an array may contain references to subarrays. If, starting from any
> array type, one considers its component type, and then (if that is also an
> array type) the component type of that type, and so on, eventually one must
> reach a component type that is not an array type; this is called the *element
> type* of the original array, and the components at this level of the data
> structure are called the elements of the original array.
Reading that - I thought I'd 'got' the difference, but then in 10.1 (a
para later) the terms seem to used synonomously!
> An array type is written as the name of an *element type* followed by some
> number of empty pairs of square brackets []. The number of bracket pairs
> indicates the depth of array nesting. An array's length is not part of its
> type.
> The element type of an array may be any type, whether primitive or reference.
> In particular:
>
> € Arrays with an interface type as the *component type* are allowed. The
> elements of such an array may have as their value a null reference or
> instances of any type that implements the interface.
> € Arrays with an abstract class type as the *component type* are allowed.
> The elements of such an array may have as their value a null reference or
> instances of any subclass of the abstract class that is not itself
> abstract.
When describing collections from the Collections framework there is
never any of this ambiguity/distinction - it is always "element type",
even when talking about a collection whose elements are themselves
collections.
Am I missing a "big idea"?
Any thoughts greatly appreciated.
Rob
email***@***.com
- 6
- XMPP Java bot loop questionI want to write a bot for XMPP (Jabber) in Java (1.6) using smack
libraries (http://www.igniterealtime.org).
I have already written a GUI client using smack, so I'm familiar with
how it works.
For the bot however, I'm in doubt about the main loop in combination
with event listeners. The bot basically just sits idly (until explicitly
stopped) listening for presence changes of contacts. The presence
changes are dealt with by a roster listener.
How would I wait for those events and have the application keep
executing? I am a bit clueless aobut threads in Java, but I have used
them in Delphi...
On a side note, if anyone can shed light on how to use the commons
daemon (http://commons.apache.org/daemon/), that would be useful later
on.
Many thanks in advance,
--
Sabine Dinis Blochberger
Op3racional
www.op3racional.eu
- 7
- ArrayList
Why this doesn't work:
ArrayList l = new ArrayList();
l.add(new String("aaa")));
String[] s = l.toArray();
JavaClassCast exception I got. What should I do?
- 8
- Help with JavaPOS pleaseHi there,
I have made an application that uses a POS printer device to print out a
receipt,
but there are genereal problems printing out .....
sometimes it prints out sometimes it doesn't (??) this is not the most major
of the
problems. The most major problem has to do with setting the style and the
layout of the printing.
After I have opened my device, claimed it everything should be ready or ??
I have checked to see what the method getFontTypefaceList()); returns
and my guess was that these numbers return different numbers that are
representatives for character sets eg fonts!!!! So I take one of these
numbers to try it out, put a number inside the method setCharacterSet(850);
yes .. 850 for instamce ... then I restart my application to see if the
output
is different, but it is not. I wonder why.
and yes I have tried several other methods in the POSprinter class and
by means of the POSprinterConst class too.
Does anyone have any experience with this or am I left to keep
experimenting?
I also need to find out how to set Linebreaking, linedistancing etc etc bold
italic and so on.
Regards
Carl
- 9
- public static final - compilation errorOn Tue, 28 Jun 2005 17:49:11 +0200, Kamil Roman wrote:
> Hi,
>
> is it possible to initialize a public static final member of a class in
> the class' constructor? I try to do this and I receive error message:
>
> variable PLUS is declared final; cannot be assigned.
{... code ...]
No, the static finals need to be initialized before that. Why don't you
use a static initializer block (static { /* ... */ }), which would be
called at class load, in which you can initialize your members.
--
You can't run away forever,
But there's nothing wrong with getting a good head start.
--- Jim Steinman, "Rock and Roll Dreams Come Through"
- 10
- odd mouselistener issueHi Guys
I'm probably doing something stupid... but:
I've got a JFrame with borderlayout. In the centre box, I've got a
JPanel. If I add a mouselistener to the jframe, it works fine (but
I've got coords relative to the frame which is correct but not what I
want - I want coords relative to the panel). However, when I add the
mouselistener to the panel, I get no mouseevents being returned at all.
Any ideas in what way I might be being stupid?
TIA
Peter.
- 11
- Can I restrict permissions at runtime?I have an editor application that I've writen that needs to read and
write XML files to disk. I'd like to extend this program by allowing
users to extend my editor by plugging in custom code they compile using
certain interfaces. My editor will call their code to gain use of
their functions.
However, this plugin code is untrusted, and I don't want it to access
the filesystem or network. Is there some way I can create a sandbox
within my program in which I can run this custom code and be sure that
it cannot do things like write to the filesystem? Perhaps create a
separate thread with special restricted permissions?
Mark McKay
- 12
- Java Newbie Question: Character Sets, Unicode, et al [Long]Roedy Green wrote:
> Ve need some definitions that make clear the distinction between:
> an character set,
> a character
> a glyph
> a font
> an encoding.
I'll take a stab at it.
I decided to see what Unicode had to say on the matter. That seemed
relevant, but may have been a mistake. In any event, here are some
possibly relevant defintions from the Unicode 4.0 glossary
(http://www.unicode.org/glossary/):
==== From the Unicode 4.0 Glossary ====
Abstract Character. A unit of information used for the organization,
control, or representation of textual data. (See Definition D3 in
Section 3.3, Characters and Coded Representations .)
Character. (1) The smallest component of written language that has
semantic value; refers to the abstract meaning and/or shape, rather than
a specific shape (see also glyph), though in code tables some form of
visual representation is essential for the reader's understanding. (2)
Synonym for abstract character. (See Definition D3 in Section 3.3,
Characters and Coded Representations .) (3) The basic unit of encoding
for the Unicode character encoding. (4) The English name for the
ideographic written elements of Chinese origin. (See ideograph (2).)
Character Encoding Form. Mapping from a character set definition to the
actual code units used to represent the data.
Character Encoding Scheme. A character encoding form plus byte
serialization. There are seven character encoding schemes in Unicode:
UTF-8, UTF-16, UTF-16BE, UTF-16LE, UTF-32, UTF-32BE and UTF-32LE.
Character Set. A collection of elements used to represent textual
information.
Coded Character Set. A character set in which each character is assigned
a numeric code point. Frequently abbreviated as character set, charset,
or code set.
Code Point. (1) A numerical index (or position) in an encoding table
used for encoding characters. (2) Synonym for Unicode scalar value.
Code Unit. The minimal bit combination that can represent a unit of
encoded text for processing or interchange. (See Definition D5 in
Section 3.3, Characters and Coded Representations .)
Encoded Character. An abstract character together with its associated
Unicode scalar value (code point). By itself, an abstract character has
no numerical value, but the process of "encoding a character" associates
a particular Unicode scalar value with a particular abstract character,
thereby resulting in an "encoded character."
Encoding Form. (See character encoding form.)
Encoding Scheme. (See character encoding scheme.)
Font. A collection of glyphs used for the visual depiction of character
data. A font is often associated with a set of parameters (for example,
size, posture, weight, and serifness), which, when set to particular
values, generate a collection of imagable glyphs.
Glyph. (1) An abstract form that represents one or more glyph images.
(2) A synonym for glyph image. In displaying Unicode character data, one
or more glyphs may be selected to depict a particular character. These
glyphs are selected by a rendering engine during composition and layout
processing. (See also character.)
Glyph Image. The actual, concrete image of a glyph representation having
been rasterized or otherwise imaged onto some display surface.
==== End of Glossary Excerpt ====
Note: the glossary does not contain a definition of "character
encoding", but it seems to be used in the Unicode context as an
abbreviation for "character encoding form" (_not_ "character encoding
scheme").
The Java documentation is a bit confused and inconsistent in its
terminology with respect to characters, character sets, and character
encodings. For instance "the Java platform uses Unicode as its native
character encoding" (i18n docs), but at the same time UTF-8 and UTF-16
are referred to as "character encodings" that all Java implementations
must support. Elsewhere in the docs these are the names of "charsets",
which is to say that in some places the docs call them "encodings" and
in others "charsets." Moreover, in Java 1.4 there is now
java.nio.charset.Charset, "A named mapping between sequences of
sixteen-bit Unicode characters and sequences of bytes." This is
consistent with MIME, but different from Unicode usage (which would call
such a thing a "character encoding scheme", except that it also implies
a certain collection of characters to which it can apply).
RFC 2045 (MIME) says, in part:
NOTE: The term "character set" was originally to describe such
straightforward schemes as US-ASCII and ISO-8859-1 which have a
simple one-to-one mapping from single octets to single characters.
Multi-octet coded character sets and switching techniques make the
situation more complex. For example, some communities use the term
"character encoding" for what MIME calls a "character set", while
using the phrase "coded character set" to denote an abstract mapping
from integers (not octets) to characters.
That describes terminology similar to Unicode's current terminology, but
not exactly the same.
Java documentation has also changed over the years with regard to how it
names these things.
What a muddle.
As this is a Java newsgroup, we are stuck with the inconsistencies of
the Java documentation, at least to some extent. We are also stuck with
the ambiguity of some of our terms (note, for instance, the four (four!)
different definitions of "character" above -- I find that I personally
use the word in each of those ways). On the other hand, there seem to
be some points on which there is little disagreement (at least in
official douments) such as a "font" as a collection of glyphs, a "glyph"
as a depiction of a character, and a definite distinction between glyphs
and characters (whatever those are).
Luckilly, in a Java context there is little call for usage of the term
"character set" in the Unicode sense, so it seems reasonable and
appropriate that in this venue we should use it in the MIME / Java NIO
sense (as defined by java.nio.charset.Charset.) "Charset" is a synonym.
By an "encoding" or "character encoding", I think we generally mean what
Unicode calls a "character encoding scheme" with the implicit
recognition that in a Java context the "character encoding form" is the
one defined by Unicode. This is closely related to a "charset" as
defined in the previous paragraph.
That leaves only "character" of the five terms of interest, and I don't
think I can do much better than the Unicode glossary there, except to
note the existence of class java.lang.Character, a related but distinct
entity. A character is definitely distinct from a glyph -- the latter
is a possible representation (or part of one) of the former, for some of
the defintions of the former.
John Bollinger
email***@***.com
- 13
- What will be your DAO design ?For the following tables, which is a general rdbms design, what classes will
you create for accessing these tables ?
Table 1 : Group
group_id (PK)
group_desc
Table 2 : User
user_id (PK)
user_name
Table 3 : Group_User
group_id (FK)
user_id (FK)
- 14
- Help sought trying to add java to mozilla 1.5
I've downloaded and gotten mozilla 1.5 to work on my desktop machine.
However, when I visit Java enabled sites, I get a popup that tells
me I am missing the plugin for the java-vm applet type. When I say
"download it", the only links are for windows and linux, and I'm
not using either of these.
In the java 1.4.2_01 directory I have on my machine is a rje/plugin/sparc/ns610
directory in which there is a .so file. But I don't see any instructions
on what all I need to connect things together.
When I try to copy that .so file into my $HOME/.mozilla/plugins directory,
mozilla 1.5 crashes attempting to access the java applets. If I
remove the .so, then I get a popup telling me I need a plugin.
Can anyone provide additional ideas on what might be missing?
--
<URL: http://wiki.tcl.tk/ > In God we trust.
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
<URL: mailto:email***@***.com > <URL: http://www.purl.org/NET/lvirden/ >
- 15
- Socializing site EXCLUSIVELY for TECHIESTechnopax.com, (http://www.technopax.com) the first socializing web
portal exclusively catering to the IT Professionals world over is
launched.
This web portal will be a common online platform for IT industry
related professionals. Technopax.com primarily targets computer
software and hardware professionals, networking & system
administrators, nano Technologists, bio-technologists, graphics &
animation designers, BPO/Call Center/ITES employees, telecom experts,
employees of IT Departments of all business organizations and
technology students etc as its members.
According to the promoters, an online platform exclusively for Techies
will improve their technical and professional skills through the
sharing of knowledge base, methodologies and skill sets. Apart from
building vast friends circle, this will also help them to be abreast
with the latest developments that happen in the tech front world over.
Technopax.com has many features for the members to collaborate and
socialize. It has text/audio and video chat, online clubs, events,
forums, classified advertisements, discussion rooms, music and video
sharing, web profiles etc. Please verify.
|
|
|