Problem with j2sdk

pls help,
i wrote an object oriented class, two classes, the first is dependent on the second.i compilied it fine both when i try to run it tells me:
Exception in thread "main" java.lang.NoSuchMethodError: main.
pls this stuff is turnin me crazy, someone help plsssssssssss.

Hopefully this example helps (with getting duke money)::
Object-oriented class:::
2 classes :1 depends (instance of) another class
*can put classes in 2 different .java files, remember to just run the
*class file with  <public static void main> method in it
------------------------------------------- Test.java //compile me
import printerObj;
public class Test{
public static void main(String a[]){
printerObj objOfPrinterClass = new printerObj(); //creating object of
objOfPrinterClass.print(); //other class
------------------------------------------- printerObj.java
import java.io.*; // I think u can put here or in other class, i should
// work either way
class printerObj {
public void print(){
System.out.println("Printing using object of the printerObj class");
*also if you just compile the Test.java, printerObj.java such compile automatically. if not check import statement in the Test.java file.
------ Hope this helps, Jimdogee

Similar Messages

  • Problem with J2SDK setup

    Hi all,
    I am experiencing problems with my J2SDK setup. I think my problem due to many previous versions of JDKs.
    I have re-installed JSDK1.4.2_03, set the "path" variable to "C:\JSDK1.4.2_03".
    When I compile using "javac" I get an error saying "javac" is not recognised.
    When I compile using "C:\j2sdk1.4.2_03\bin\javac Freq.java" no error is thrown.
    Every time I try to run a java file, I always get the NoClassDefFound error. When run with the -verbose option, files are loaded from C:\Program Files\Java\j2re1.4.2_03\bin - is this correct?
    I have removed all previous references to java in the registry editor.
    I would be really grateful to you (and anyone else) for help with this problem.
    Regards,
    Vipul

    Hi,
    Thanks for getting back to me. I have altered my CLASSPATH and path. Unfortunately it is still not working. I have run java using the full path to the jdk and the jars are loaded in from the right place, but I still get the noclassdeffound error. I have removed all references to CLASSPATH and PATH. When I run with the verbose option (with no ref to the jdk in any variable), the jar files are loaded in from C\program files\java\j2re1.4.2_03! But there is no reference to this location in any variable.My j2sdk is installed in C:\j2sdk1.4.2_03.
    Currently ,
    CLASSPATH =".;C:\Program Files\eclipse\plugins\org.eclipse.swt.win32_2.1.1\ws\win32\swt.jar;C:\cygwin\usr\share\postgresql\java\postgresql.jar; C:\Program Files\Database Report Writers\DB Drivers\pg73jdbc.jar "
    And PATH = " %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\cygwin\bin;C:\Program Files\Common Files\Adaptec Shared\System;C:\MSSQL7\BINN;C:\tools\ant\apache-ant-1.5.3-1\bin;C:\Program Files\cvsnt;C:\tools\ant\apache-ant-1.5.3-1\bin;C:\tools\maven\maven-1.0-beta-11-SNAPSHOT\bin "
    Please help.
    Ciao,
    Vipul

  • WAS 6.40 Java Edition - problems with j2sdk-1_4_2_10

    Just for info!
      Several installations without success
      VMWare 5.0.0
      Windows 2003 SP1
      j2sdk-1_4_2_10
      2GB RAM
        Steps 18 or 22 errrors.
      Put j2sdk-1_4_2_08 - OK
      cheers!

    Pl. check OSS Note 716604. SAP recommends using 1.4.2_09 SDK.
    Extract from the Note:
    Quote:
    Access to appropriate Sun J2SE Version:
    Please use Sun J2SE 1.4.2_09 SDK (or higher 1.4.2 versions after they will become available). It is not recommended to use versions lower than 1.4.2_09. Please also do not use J2SE 5.0
    Important note:
    In contrast to the recommendation above please do not use J2SE 1.4.2_10  as it has problems during installation. The problem is under investigation.
    Unquote:
    I have used 1.4.2_09 and have no problems with the installation.
    Regards
    Chandu
    P.S : Pl. reward points if it is helpful to you.

  • Problem with J2sdk instalation

    Hi!
    I'm a java begginer. (I started 1 hour ago! )
    After installing j2sdk, some applets stop working (e.g some applets in java.sun.com ) , i.e they return the message "java.lang.ClassNotFoundException" (something like this).
    I'm working in NT environment, with a Pentium 200 MGHZ MMX, and IE 5.5. I have already try to install javabeans, and flash 5.0 . When remove the j2sdk this problem disapears, and everything runs well.
    I've also verified that java programs that use the Arrays class, in the compilation process, returns the error: "Can't resolve symbol Arrays.Sort"
    ^
    Please help me, even if it sounds too stupid!
    Greetings
    Joao Nora

    Hi, don't forget to check out your PATH and CLASSPATH, but I am sure you already have.
    I think your problem is Arrays.Sort, it should be Arrays.sort ... hope this helps :-)
    Good luck

  • Problem with J2SDK Mobile

    I used to run my programs on WTK 2.0 and Sun ONE Studio 4 Update 1, and every thing worked fone. But now, even when I try to run the WTK demos, i get the following error:
    Running with storage root DefaultColorPhone
    java.lang.SecurityException: untrusted domain is not configured
    at com.sun.midp.security.Permissions.forDomain(+98)
    at com.sun.midp.dev.DevMIDletSuiteImpl.create(+15)
    at com.sun.midp.dev.DevMIDletSuiteImpl.create(+33)
    at com.sun.midp.main.Main.runLocalClass(+20)
    at com.sun.midp.main.Main.main(+116)
    Execution completed successfully
    7679 bytecodes executed
    0 thread switches
    426 classes in the system (including system classes)
    154 dynamic objects allocated (8660 bytes)
    1 garbage collections (0 bytes collected)
    java.lang.NullPointerException
    at com.sun.kvem.midp.MIDP.run(Unknown Source)
    at com.sun.kvem.environment.EmulatorInvoker.runEmulatorImpl(Unknown Source)
    at com.sun.kvem.environment.EmulatorInvoker.runEmulatorSameVM(Unknown Source)
    at com.sun.kvem.environment.EmulatorInvoker.runEmulator(Unknown Source)
    at com.sun.kvem.environment.ProfileEnvironment$KVMThread.runEmulator(Unknown Source)
    at com.sun.kvem.environment.ProfileEnvironment$KVMThread.run(Unknown Source)
    Can you tell me what is wrong?

    i tried the classic microsoft approach: i
    uninstalled wtk 2.0 and reinstalled it.
    it works fine now...Yeah, that usually works :)
    anyway, just for the record, where is the MIDP_HOME
    variable?It's an environment variable. Here's a link on setting these variables:
    http://java.sun.com/docs/books/tutorial/uiswing/start/_envVariables.html

  • Problems with j2re and j2sdk's j2re

    OK I know that subject doesn't make much sense, but this is rather hard to explain.
    Has anyone else had any issues with the the Java2 1.4 SDK's jre (The software dev kit along with the jre) and just the 1.4 jre installation files? Basically it's this:
    j2re-1_4_0-win.exe - JRE ONLY
    j2sdk-1_4_0-win.exe - SDK + JRE
    Even though both of these files install the same version of the jre, I'm thinking they are different in some way (either a bug or on purpose I don't know).
    I've been developing some ESRI MapOjects Java applications and ran into this issue when making an applet.
    Installing the jre with j2sdk-1_4_0-win.exe will make the applet work, but just installing the jre itself (j2re-1_4_0-win.exe - the one your web browser will make you d/l if you don't have jre 1.4) will make the applet unworkable.
    The particular problem is with file access. I download the files to the local machine then use them later on in the program. The sdk-jre doesn't have a problem with this, but the jre only version does for some reason. Even after downloading the files and checking if they exist, are readable, and are writable (all three returned true) it still treats the files as nonexistant.
    Obviously this is very puzzling and was wondering if anyone else has had something like this happen to them, and if not maybe Sun should look into this since this has really made my applet pointless (what's the point of using an applet if you have to d/l a 30+ meg file in order to run it vs the 9 meg file that won't run it :) ).
    Not that my applet is Sun's major concern, :) but if this becomes a reocurring problem with others then it should be investigated.
    To answer the first question if any will arise in this thread, yes my applet is digitally signed and it's not just my computer. I have this happen on four other computers until I saw the pattern and installed the sdk on them. Then the applet started to work.

    There is the possibility of differences between the various runtimes, but I can't see them causing the type of problem you note.
    A separately d/l'd JRE can be either an "English-only" version or an "International" version. (The 2 installed as part of the SDK are the "International" version.)
    Both JRE's that are installed as part of the SDK have 2 separate bytecode-to-native compiler binaries - Client and Server versions, selectable via java.exe options. A separately d/l'd JRE has only the Client binary (both English-only and International versions).
    Using the current Plugins, it's not necessary to use the HTML converter (quoted from Sun):
    "Beginning with J2SE 1.3.1_01a, Java Plug-in supports <applet> tags for launching applets and for initiating autodownload of the JRE/Java Plug-in on Microsoft Windows platforms. For more information, see Java Plug-in Developer Documentation"
    I'm of the opinion that some environment difference - classpath, Plugin settings, etc. is causing the difference between runtimes.

  • Problems with xml and j2sdk-1.5

    Hello everyone,
    until i upgraded my version of the jdk (from 1.4.2 to 1.5.0) everything was working fine concerning xml-processing. Now i am having problems with at least two methods that were working just fine before the upgrade.
    public void createRootElement(String s) {
            Element root = doc.createElement(s);
            doc.appendChild(root);
    //that was the first one
    public void addFirstChildElement(String element, String node) {
            Element root = doc.getDocumentElement();
            System.out.println("Rootelement: "+root.toString()+" Element: "+element+" node: "+node);
            try {
                Element nextElement = doc.createElement(element);
                System.out.println("Nextelement "+nextElement.toString());
                root.appendChild(nextElement);
                nextElement.appendChild(doc.createTextNode(node));
            catch (DOMException e) {
                e.printStackTrace();
    //the second onethe problem is now that for some reasong nothing is written into the xml document except "<?xml version='1.0' encoding='UTF-8' ?>".
    The result of the System.out.println command in the second method is:
    Rootelement: [Preferences: null] Element: DefaultLanguage node: de
    As i mentioned already everything was fine before the upgrade, but now i really don't have a clue what's wrong...
    Any ideas?
    Thanks in advance...

    It seems that the toSring() method doesn't print out the complete XMl structure. anymore.
    Only some "debug" information is printed.
    You have to use a transfomer (text transfomer) to print out the XML in text form...

  • Problem with type 4 driver using oracle 10g

    HI,
    I am unable to establish a type 4 connection with oracle 10g.
    Specs:
    Driver used: OracleDriver that comes with the ojdbc14.jar along with oracle 10g
    JDK used: Tried using both j2sdk1.4.2 and using JDK 5.0
    JRE: Again, JRE that was shipped with j2sdk 1.4.2 and JRE 5.0
    OS: Windows XP sp2
    I am able to compile the following piece of code, so there is no classpath problem, etc.
    When I try to run the program, the exception thrown is "No Suitable Driver"
    There is no problem with the TNSListener, etc...even if all Oracle related services in 'services.msc' are Started/Stopped, the error remains.
    I am, however, able to establish the connection using type1 driver.
    Please Help!
    import java.sql.*;
    import java.io.*;
    class TestConn
         Connection connection;
         Statement statement;
         ResultSet resultset;
         public void testConn() throws SQLException, ClassNotFoundException
              DriverManager.registerDriver(new oracle.jdbc.driver.OracleStatement());
              //DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
              connection = DriverManager.getConnection("oracle:jdbc:thin:@127.0.0.1:1521", "scott", "tiger");
              //connection = DriverManager.getConnection("jdbc:odbc:dsn1", "scott", "tiger");
              System.out.println("Connection Established");
              statement = connection.createStatement();
              resultset = statement.executeQuery("select ename from emp");
              while(resultset.next())
                   System.out.println(resultset.getString(1));
    class Test
         public static void main(String args[]) throws SQLException, ClassNotFoundException
              TestConn obj = new TestConn();
              obj.testConn();
    };

    The JDBC URL should include the database SID. For example, if the database SID is Orcl
    connection = DriverManager.getConnection("oracle:jdbc:thin:@127.0.0.1:1521:Orcl", "scott", "tiger");

  • Problem with ImageIO.read()

    I have a problem with loading picture from file to variable Image img. Function ImageIO.read(fileIn) return always null pointer (whereas fileIn!=null). I'm using j2sdk-1_4_2_0. The same problem problem is in WindowsXP SP2 and Fedora 3 64bit.
    Here is code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.net.*;
    import java.awt.image.*;
    import javax.imageio.*;
    import java.net.URL;
    import javax.imageio.ImageIO;
    import java.io.*;
    public class Converter extends JPanel implements ActionListener {
    JPanel mainPanel, info1Panel,info2Panel,convertionPanel, fSizePanel,displayPanel;
    JCheckBox enableConvertion;
    JButton selectFile,doIt,close;
    JRadioButton size1,size2;
    ButtonGroup sizeGroup;
    ImageIcon imagePrev;
    JRadioButton[] convertion = new JRadioButton[2];
    Image img;
    JLabel previewLabel;
    JFileChooser fc;
    File fileIn = new File("10.jpg");
    File fileOut;
    public Converter() {
    // Tworzenie paneli
    mainPanel=new JPanel();
    mainPanel.setLayout(null);
    info1Panel=new JPanel();
    info2Panel=new JPanel();
    convertionPanel=new JPanel(new BorderLayout());
    fSizePanel=new JPanel();
    displayPanel= new JPanel();
    //Tworzenie pozostalych elementow
    enableConvertion = new JCheckBox("Enable JPG <-> PNG");
    selectFile = new JButton("Select File");
    doIt = new JButton("Do it!");
    close= new JButton("Close");
    fc = new JFileChooser();
    size1 = new JRadioButton("The same resolution");
    size2= new JRadioButton("Resize image to target size of file");
    JLabel previewLabel = new JLabel();
    ButtonGroup sizeGroup = new ButtonGroup();
    imagePrev= new ImageIcon();
    // proba ulozenia elementow na ramce
    Insets insets = mainPanel.getInsets();
    Dimension size = selectFile.getPreferredSize();
    selectFile.setBounds(15 + insets.left, 15 + insets.top,size.width, size.height);
    doIt.setBounds(15 + insets.left,15+5+ insets.top+size.height,size.width, size.height);
    close.setBounds(15+insets.left,15+2*(5+size.height)+insets.top,size.width,size.height);
    convertionPanel.setBounds(10,150,250,90);
    convertionPanel.setBorder(BorderFactory.createCompoundBorder(
    BorderFactory.createTitledBorder("Convertion"),
    BorderFactory.createEmptyBorder(0,5,5,5)));
    info1Panel.setBounds(150,10,200,140);
    info1Panel.setBorder(BorderFactory.createCompoundBorder(
    BorderFactory.createTitledBorder("Source File Information"),
    BorderFactory.createEmptyBorder(0,5,5,5)));
    info2Panel.setBounds(360,10,200,140);
    info2Panel.setBorder(BorderFactory.createCompoundBorder(
    BorderFactory.createTitledBorder("Target File Information"),
    BorderFactory.createEmptyBorder(0,5,5,5)));
    fSizePanel.setBounds(10, 250, 250, 90);
    fSizePanel.setBorder(BorderFactory.createCompoundBorder(
    BorderFactory.createTitledBorder("File size"),
    BorderFactory.createEmptyBorder(0,5,5,5)));
    fSizePanel.setLayout(new GridLayout(2,0));
    displayPanel.setBounds(270,150,290,190);
    displayPanel.setBorder(BorderFactory.createCompoundBorder(
    BorderFactory.createTitledBorder("Display"),
    BorderFactory.createEmptyBorder(0,5,5,5)));
    previewLabel.setHorizontalAlignment(JLabel.CENTER);
    previewLabel.setVerticalAlignment(JLabel.CENTER);
    previewLabel.setVerticalTextPosition(JLabel.CENTER);
    previewLabel.setHorizontalTextPosition(JLabel.CENTER);
    previewLabel.setBorder(BorderFactory.createCompoundBorder(
    BorderFactory.createLoweredBevelBorder(),
    BorderFactory.createEmptyBorder(5,5,5,5)));
    previewLabel.setBorder(BorderFactory.createCompoundBorder(
    BorderFactory.createEmptyBorder(0,0,10,0),
    previewLabel.getBorder()));
    size1.setSelected(true);
    mainPanel.add(info1Panel);
    mainPanel.add(info2Panel);
    mainPanel.add(convertionPanel);
    mainPanel.add(fSizePanel);
    mainPanel.add(displayPanel);
    //osadzamy w odpowiednich panelach elementy
    mainPanel.add(selectFile);
    mainPanel.add(doIt);
    mainPanel.add(close);
    sizeGroup.add(size1);
    sizeGroup.add(size2);
    fSizePanel.add(size1);
    fSizePanel.add(size2);
    displayPanel.add(previewLabel);
    convertionPanel.add(enableConvertion);
    selectFile.addActionListener(this);
    public void actionPerformed(ActionEvent e) {
    int returnVal = fc.showOpenDialog(Converter.this);
    if (returnVal == JFileChooser.APPROVE_OPTION)
    File fileIn = fc.getSelectedFile();
    JFrame frame1=new JFrame();
    JOptionPane.showMessageDialog(frame1, fileIn.getName());
    if(fileIn==null)
    JFrame frame2 = new JFrame();
    JOptionPane.showMessageDialog(frame2,"FileIN==NULL");
    //############## PROBLEM IS HERE ###########################
    try
    Image img=ImageIO.read(fileIn); // HERE IS THE PROBLEM: img==NULL
    // WHERAS fileIn!=NULL
    }catch (IOException event){}
    if (img==null)
    JFrame frame2 = new JFrame();
    JOptionPane.showMessageDialog(frame2,"img==NULL");
    private static void createAndShowGUI() {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);
    //Create a new instance of LunarPhases.
    Converter conv = new Converter();
    //Create and set up the window.
    JFrame convFrame = new JFrame("Conversion JPG <-> PNG");
    convFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    convFrame.setContentPane(conv.mainPanel);
    Insets insets = convFrame.getInsets();
    convFrame.setSize(600 + insets.left + insets.right,400+insets.top + insets.bottom);
    convFrame.setVisible(true);
    public static void main(String[] args) {
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    }

    //############## PROBLEM IS HERE ###########################
    try {
    Image img=ImageIO.read(fileIn); // HERE IS THE PROBLEM: img==NULL
    // WHERAS fileIn!=NULL
    } catch (IOException event){}
    if (img==null) {
        JFrame frame2 = new JFrame();
        JOptionPane.showMessageDialog(frame2,"img==NULL");
    }1. Please use [code] tags when posting code -- it makes the code more readable.
    2. When posting code, post a minimal example program. You could have filtered
    out all the extraneous GUI code, for example. Remember: the shorter the code, the
    more likely it is a forum member will read it! Posting long runs of code only
    hurts yourself.
    3. All that being said, your problem is a simple oversight: notice that the
    variable "img" in your try block is a local variable, not the field named "img"
    than you test after the try block.
    You should have written:
    try {
        img=ImageIO.read(fileIn);
    } catch (IOException event){
        e.printStackTrace();
    }

  • Command "java" in Windows XP Home Edition with J2SDK 1.4.0-beta3

    Hi
    After succesfully compiling a Java-source, I can't run it. Whenever I type: "java HelloWorldApp.class" it returns "Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp" as described on http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html#2c
    I tried to resolve the problem by doing what's said on the url above, but it doesn't work. I run Windows XP Home Edition with J2SDK 1.4.0-beta3 installed not on C. but on F:\j2sdk1.4.0-beta3
    Does anyone have a solution? It would be greatly appreciated.

    Hi
    I don't understand what is said on the help page. My mother tongue is Dutch, although I understand most English texts. Also, I run Windows XP, which doesn't seem to have a classpath variable. When I type what is said "set classpath=", nothing happens. After that, I try again, and is still doesn't work.
    But running Java without extension works. Thanks man.

  • Problem with PointBase v4.2, goes away in v4.3

    Hey,
    I've been using PointBase as the database backend for CMP in app server 7, and there's a problem with PointBase. I can't create an auto-increment (identity) field in one table, then in the same table have a foreign key reference to another table which has it's primary key also as an identity field.
    This problem goes away in PointBase v4.3. I think this is a major problem as this is very common when developing (prototyping whatever) database apps using identity fields to uniquely ID the table.
    My suggestion is that we bundle an evaluation of 4.3, instead of 4.2. No changes would need to be made to any documentation, and the jar file uses the same package names as that of v4.2.
    Just my thoughts, I think that we can add value at very minimal cost.
    Clint.

    Hi Clint,
    Thanks for the heads up.
    App Server 7 will be shipping with PointBase Server 4.2 because it has gone through quite a bit of certification with the specific version of the product. Of course, as you noticed, there might be issues with some features in 4.2 that are not tested in our test suite. However, we cannot simply swap out 4.2 for 4.3 and ship the App Server 7 product without further planning and performing another round of certification tests. Bundling of 4.3 or greater will have to wait for the follow on release of the application server. (Same could be said of Ant 1.5.x, J2SDK 1.4.1, etc. All components which need to be certified with the app server product).
    If you are Sun employee, please contact me and I can explain it in more detail.
    Thanks again,
    [email protected]

  • Strange problem with Istant DB

    Hello,
    i have a strange problem with idb and classloader... if i try to connect to my db using a servlet, i get a ClassNotFoundException, but if i try to connect to it normally, it's all ok...
    C:\jwsdp\webapps\ROOT\prova\DB>java DataBase
    Enhydra InstantDB - Version 3.26
    The Initial Developer of the Original Code is Lutris Technologies Inc.
    Portions created by Lutris are Copyright (C) 1997-2001 Lutris Technologies, Inc.
    All Rights Reserved.
    Database movies is shutting down...
    Database movies shutdown complete.
    What's the problem??? why
    Class.forName("org.enhydra.instantdb.jdbc.idbDriver");
    in a servlet application catch a ClassNotFoundException???
    this is my classpath:
    %JAXP_HOME%\lib\jaxp-api.jar;
    %JAXB_LIBS%\jaxb-api.jar;
    %JAXB_LIBS%\jaxb-ri.jar;
    %JAXB_LIBS%\jaxb-xjc.jar;
    %JAXB_LIBS%\jaxb-libs.jar;
    %JWSDP_HOME%\common\lib\catalina-ant.jar;
    %JWSDP_HOME\common\lib\servlet.jar;
    C:\idb\Classes;
    C:\idb\Classes\idb.jar;
    C:\idb\Classes\idbexmpl.jar;
    C:\idb\Classes\jta-spec1_0_1.jar;
    C:\j2sdk\lib;
    C:\jwsdp\jaxb-1.0\lib;
    C:\jwsdp\jaxb-1.0;
    C:\jwsdp\jaxb-1.0\lib\jaxb-api.jar;
    C:\jwsdp\jaxb-1.0\lib\jaxb-libs.jar;
    C:\jwsdp\jaxb-1.0\lib\jaxb-ri.jar;
    C:\jwsdp\jaxb-1.0\lib\jaxb-xjc.jar;
    Thanks, Marco

    There should be a xml configuration file for tomcat, and it should be possible to state additional classpaths there. But I'd suggest to use the pre-configured classpaths. In which directory does your servlet class reside, or where is your document root for the web application of this servlet?
    Regards

  • Printing problem with Windows : Win32PrintService

    Hi,
    I wrote a program which I run under Windows, and prints a .gif image with some text.
    I have tested it vith various printers, and it works well.
    But with a specific printer (Datamax Allegro, driver by Seagull) I get this exception :
    java.lang.ArrayIndexOutOfBoundsException
    at sun.print.Win32PrintService.getDefaultAttributeValue(Win32PrintService.java:785)
    at sun.print.Win32PrintJob.printableJob(Win32PrintJob.java:414)
    at sun.print.Win32PrintJob.print(Win32PrintJob.java:343)
    I have downloaded the whole source for j2sdk 1.4.0, but did not find the source for
    Win32PrintService and Win32PrintJob, so I can not run it in debug mode
    Does anyone know where I can find that source ,
    ... or has any idea on how to avoid that exception ?
    Thanks for any advice
    Michel Clabon
    [email protected]

    Hi,
    But with a specific printer (Datamax Allegro, driver
    by Seagull) I get this exception :
    java.lang.ArrayIndexOutOfBoundsExceptionHi have the same problem with a Seiko smart label printer 240
    I have downloaded the whole source for j2sdk 1.4.0,
    but did not find the source for
    Win32PrintService and Win32PrintJob, so I can not run
    it in debug mode
    Does anyone know where I can find that source ,j2se\src\win32\classes\sun\print\Win32PrintService.java
    AFAIR you have to download the sources separately somewhere from sun.
    ... or has any idea on how to avoid that exception ?it tries to access an elment of a non-existing array.
    (guessing: the array should contain some media information and the printer driver does not report any media data?)
    from memory, something like:
    aset.add(MediaSize.ISO_A4);
    may help, if this does make sense for you.
    I posted a bug to sun, so lets wait and see...

  • A problem with threads

    I am trying to implement some kind of a server listening for requests. The listener part of the app, is a daemon thread that listens for connections and instantiates a handling daemon thread once it gets some. However, my problem is that i must be able to kill the listening thread at the user's will (say via a sto button). I have done this via the Sun's proposed way, by testing a boolean flag in the loop, which is set to false when i wish to kill the thread. The problem with this thing is the following...
    Once the thread starts excecuting, it will test the flag, find it true and enter the loop. At some point it will LOCK on the server socket waiting for connection. Unless some client actually connects, it will keep on listening indefinatelly whithought ever bothering to check for the flag again (no matter how many times you set the damn thing to false).
    My question is this: Is there any real, non-theoretical, applied way to stop thread in java safely?
    Thank you in advance,
    Lefty

    This was one solution from the socket programming forum, have you tried this??
    public Thread MyThread extends Thread{
         boolean active = true;          
         public void run(){
              ss.setSoTimeout(90);               
              while (active){                   
                   try{                       
                        serverSocket = ss.accept();
                   catch (SocketTimeoutException ste){
                   // do nothing                   
         // interrupt thread           
         public void deactivate(){               
              active = false;
              // you gotta sleep for a time longer than the               
              // accept() timeout to make sure that timeout is finished.               
              try{
                   sleep(91);               
              }catch (InterruptedException ie){            
              interrupt();
    }

  • Problem with Threads and a static variable

    I have a problem with the code below. I am yet to make sure that I understand the problem. Correct me if I am wrong please.
    Code functionality:
    A timer calls SetState every second. It sets the state and sets boolean variable "changed" to true. Then notifies a main process thread to check if the state changed to send a message.
    The problem as far I understand is:
    Assume the timer Thread calls SetState twice before the main process Thread runs. As a result, "changed" is set to true twice. However, since the main process is blocked twice during the two calls to SetState, when it runs it would have the two SetState timer threads blocked on its synchronized body. It will pass the first one, send the message and set "changed" to false since it was true. Now, it will pass the second thread, but here is the problem, "changed" is already set to false. As a result, it won't send the message even though it is supposed to.
    Would you please let me know if my understanding is correct? If so, what would you propose to resolve the problem? Should I call wait some other or should I notify in a different way?
    Thanks,
    B.D.
    Code:
    private static volatile boolean bChanged = false;
    private static Thread objMainProcess;
       protected static void Init(){
            objMainProcess = new Thread() {
                public void run() {
                    while( objMainProcess == Thread.currentThread() ) {
                       GetState();
            objMainProcess.setDaemon( true );
            objMainProcess.start();
        public static void initStatusTimer(){
            if(objTimer == null)
                 objTimer = new javax.swing.Timer( 1000, new java.awt.event.ActionListener(){
                    public void actionPerformed( java.awt.event.ActionEvent evt){
                              SetState();
        private static void SetState(){
            if( objMainProcess == null ) return;
            synchronized( objMainProcess ) {
                bChanged = true;
                try{
                    objMainProcess.notify();
                }catch( IllegalMonitorStateException e ) {}
        private static boolean GetState() {
            if( objMainProcess == null ) return false;
            synchronized( objMainProcess ) {
                if( bChanged) {
                    SendMessage();
                    bChanged = false;
                    return true;
                try {
                    objMainProcess.wait();
                }catch( InterruptedException e ) {}
                return false;
        }

    Thanks DrClap for your reply. Everything you said is right. It is not easy to make them alternate since SetState() could be called from different places where the state could be anything else but a status message. Like a GREETING message for example. It is a handshaking message but not a status message.
    Again as you said, There is a reason I can't call sendMessage() inside setState().
    The only way I was able to do it is by having a counter of the number of notifies that have been called. Every time notify() is called a counter is incremented. Now instead of just checking if "changed" flag is true, I also check if notify counter is greater than zero. If both true, I send the message. If "changed" flag is false, I check again if the notify counter is greater than zero, I send the message. This way it works, but it is kind of a patch than a good design fix. I am yet to find a good solution.
    Thanks,
    B.D.

Maybe you are looking for

  • Tactic3D Sigma + X-Fi Titanium Fatal1ty ?

    Hello friends, I have a PCI-E X-Fi Titanium Fatalty sound card and I'm thinking in get a good headphone to play during midnight. I know Titanium features in Game Mode the CMSS-3D effect which offer a great improvment in games with any kind of headpho

  • Apex Function API's and column aliases

    Has anyone run into this? WHen I supply this simple query in a report page, the syntax is accepted: select apex_item.text(1,c.claim_nbr) from claim c, service_x m where c.claim_nbr = m.claim_nbr When I change it to this: select apex_item.hidden(1,c.c

  • Should Notification Center under iOS 7 be all white on black with no color?

    I've seen online reviews of iOS 7 with screenshots of the Notification Center having a textured, shimmering color style similar to the Lock Screen. But my Notification Center is a very boring black background with white text, a completely flat design

  • IPhone thinks thought headphones were connected - now dead!

    Two days ago my iPhone 4S would not work without headphones - when the headphones weren't plugged in it was like it thought they were (when I adjusted the volume it said "headphones") - I plugged the headphones in & out several times & it seemed to r

  • Package : Simple question

    Hi, A really simple question : how can i get a list of all the fonction an procedure of a package (just the name, not the the package source). DB -> 8.1.7 / openVMS Thanks... Alban