Java.sun example won't compile

hello..
I've just succefully installed the JDK and am trying a few things ou to ensure it works, which as yet it doesn't.
I'm using VIDE for the time being for my IDE
and try to compile this.... which has been taken straight out of the tutorial pages
//v 1.3
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class SwingApplication {
private static String labelPrefix = "Number of button clicks: ";
private int numClicks = 0;
public Component createComponents() {
final JLabel label = new JLabel(labelPrefix + "0 ");
JButton button = new JButton("I'm a Swing button!");
button.setMnemonic(KeyEvent.VK_I);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
numClicks++;
label.setText(labelPrefix + numClicks);
label.setLabelFor(button);
* An easy way to put space between a top-level container
* and its contents is to put the contents in a JPanel
* that has an "empty" border.
JPanel pane = new JPanel();
pane.setBorder(BorderFactory.createEmptyBorder(
30, //top
30, //left
10, //bottom
30) //right
pane.setLayout(new GridLayout(0, 1));
pane.add(button);
pane.add(label);
return pane;
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(
UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) {}
//Create the top-level container and add contents to it.
JFrame frame = new JFrame("SwingApplication");
SwingApplication app = new SwingApplication();
Component contents = app.createComponents();
frame.getContentPane().add(contents, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
the following errors occur, there are four and they all reffer to a swing component.
Type JLabel not found in the declaration of the local variable 'label'.
final JLabel label = new JLabel(labelPrefix + "0 ");
and there's a hat under the very first 'J'. Ditto for JFrame JButton and JPanel
Really confussed on this one everything seems to be in place the CLASSPATH is pointing to the lib directory where Javax et all are...
Cheers
A

well...
I'm using linix rehat 8 and my 'path' variable is set up the same as the installation instructions on a post close to this one... it is..
"PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/X11R6/bin:/usr/local/vnc:/var/www:/home/software:/usr/java/j2sdk1.4.1_01/bin:/var/home/adam/bin"
I'm new to unix and so am still a little confused.. This is the path to the executables and not the library files such as javax.swing, correct?? I have also ditched the IDE and running from the command promt. I am trying again this morning and am geting an extra error apparently.....
" Can't find default package `javax.swing'. Check the CLASSPATH environment variable and the access to the archives"
could someone explain what CLASSPATH is please as I thought it was only applicable to Windows. The javax package has been unpacked.
Cheers
Adam

Similar Messages

  • Java gui program won't compile.

    The error I am getting in my compiler is missing return statement, then ill add some braces and get a class, interface, or enum expected error, and sometimes when i add some ill end up getting a reached the end without parcing error. Can someone look at this code and tell me what I need to do to make it compile, I am pretty sure it is just a brace thing, but I have run out of ideas:
    here is the code:
    public class Lab14 implements ActionListener
    // Application variables
    private JFrame myFrame;
    private JTextField txtInput;
    private JButton cmdRun;
    private JButton cmdExit;
    private JTextArea txaOutput;
    private static Random rand = new Random();
    private double trials;
    * Schedule a job for the event-dispatching thread
    * to create and show this application's GUI.
    * @param args program arguments
    public static void main(String[] args)
    javax.swing.SwingUtilities.invokeLater(new Runnable()
    public void run()
    Lab14 myLab14 = new Lab14();
    myLab14.createAndShowGUI();
    * Create and show the graphical user interface.
    private void createAndShowGUI()
    Container myPane;
    txtInput = new JTextField(10);
    cmdRun = new JButton("Run");
    cmdRun.addActionListener(this);
    cmdExit = new JButton("Quit");
    cmdExit.addActionListener(this);
    txaOutput = new JTextArea(35, 40);
    txaOutput.setEditable(false);
    // Set up and show the application frame
    myFrame = new JFrame("Lab14");
    myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    myPane = myFrame.getContentPane();
    myPane.setLayout(new FlowLayout());
    myPane.add(new JLabel("Number of Trials"));
    myPane.add(txtInput);
    myPane.add(cmdRun);
    myPane.add(cmdExit);
    myPane.add(txaOutput);
    myFrame.pack();
    myFrame.setVisible(true);
    txtInput.requestFocus();
    * Enable user interaction.
    * @param ae the specified action event
    public void actionPerformed(ActionEvent ae)
    String number;
    String report;
    int dotSum = 0;
    int count = 0;
    int freq = 0;
    int prob = 0;
    Object source = ae.getSource();
    if (source.equals(cmdRun))
    try
    number = txtInput.getText();
    trials = Double.parseDouble(number);
    if (trials <= 0)
    throw new Exception(
    "The number of trials must be positive.");
    else
    while (count < trials)
    dotSum = dotSum + rand.nextInt(6) + 1;
    count++;
    txaOutput.setText(
    getReport(dotSum, freq, prob));
    catch (NumberFormatException nfe)
    txtInput.selectAll();
    txtInput.requestFocus();
    JOptionPane.showMessageDialog(
    myFrame,
    "The number of trials is not a number.",
    "Number Format Error",
    JOptionPane.ERROR_MESSAGE);
    catch (Exception e)
    txtInput.selectAll();
    txtInput.requestFocus();
    JOptionPane.showMessageDialog(
    myFrame,
    e.getMessage(),
    "Number Format Error",
    JOptionPane.ERROR_MESSAGE);
    else
    System.exit(0);
    * Get the report for the specified dot sum, frequency,
    * and probability. The output shows the results from
    * rolling the dice a selected number of trials.
    * @param dotSum the sum of the dots
    * @param frequency the frequency of the dice
    * @param probability the probability of rolling a specified amount
    * @return the report
    private String getReport(int dotSum,
    int freq,
    int prob)
    int count;
    int freq0;
    int freq1;
    int freq2;
    int freq3;
    int freq4;
    int freq5;
    int freq6;
    int freq7;
    int freq8;
    int freq9;
    int freq10;
    double prob0;
    double prob1;
    double prob2;
    double prob3;
    double prob4;
    double prob5;
    double prob6;
    double prob7;
    double prob8;
    double prob9;
    double prob10;
    String report;
    int numDice = 2;
    while (trials != 0)
    Dice myDice = new Dice(numDice);
    freq0 = 0;
    freq1 = 0;
    freq2 = 0;
    freq3 = 0;
    freq4 = 0;
    freq5 = 0;
    freq6 = 0;
    freq7 = 0;
    freq8 = 0;
    freq9 = 0;
    freq10 = 0;
    for (count = 0; count < trials; count++)
    switch (myDice.getDotSum())
    case 2: freq0++;
    break;
    case 3: freq1++;
    break;
    case 4: freq2++;
    break;
    case 5: freq3++;
    break;
    case 6: freq4++;
    break;
    case 7: freq5++;
    break;
    case 8: freq6++;
    break;
    case 9: freq7++;
    break;
    case 10: freq8++;
    break;
    case 11: freq9++;
    break;
    case 12: freq10++;
    prob0 = (double)freq0/(double)trials;
    prob1 = (double)freq1/(double)trials;
    prob2 = (double)freq2/(double)trials;
    prob3 = (double)freq3/(double)trials;
    prob4 = (double)freq4/(double)trials;
    prob5 = (double)freq5/(double)trials;
    prob6 = (double)freq6/(double)trials;
    prob7 = (double)freq7/(double)trials;
    prob8 = (double)freq8/(double)trials;
    prob9 = (double)freq9/(double)trials;
    prob10 = (double)freq10/(double)trials;
    double freqSum = freq0 + freq1 + freq2 + freq3 + freq4 +
    freq5 + freq6 + freq7 + freq8 + freq9 + freq10;
    double probSum = prob0 + prob1 + prob2 + prob3 + prob4 +
    prob5 + prob6 + prob7 + prob8 + prob9 + prob10;
    return
    String.format("%7s %9s %11s%n", "Dot Sum", "Frequency", "Probability")+
    String.format("%7s %9s %11s%n", "-------", "---------", "-----------")+
    String.format(" 2 %9d", freq0)+
    String.format(" %11.3f%n", prob0)+
    String.format(" 3 %9d", freq1)+
    String.format(" %11.3f%n", prob1)+
    String.format(" 4 %9d", freq2)+
    String.format(" %11.3f%n", prob2)+
    String.format(" 5 %9d", freq3)+
    String.format(" %11.3f%n", prob3)+
    String.format(" 6 %9d", freq4)+
    String.format(" %11.3f%n", prob4)+
    String.format(" 7 %9d", freq5)+
    String.format(" %11.3f%n", prob5)+
    String.format(" 8 %9d", freq6)+
    String.format(" %11.3f%n", prob6)+
    String.format(" 9 %9d", freq7)+
    String.format(" %11.3f%n", prob7)+
    String.format(" 10 %9d", freq8)+
    String.format(" %11.3f%n", prob8)+
    String.format(" 11 %9d", freq9)+
    String.format(" %11.3f%n", prob9)+
    String.format(" 12 %9d", freq10)+
    String.format(" %11.3f%n", prob10)+
    String.format("%7s %9s %11s%n", "-------", "---------", "-----------")+
    String.format("%18d", freqSum)+
    String.format("%13.3f%n", probSum);
    }

    border9 wrote:
    yes, but i wrote the bottom part of the code a while ago before I did know what an array list was, so I figured it would be easier just to paste that rather than make new code.Sounds to me like you're the type who just throws code at a wall hoping some of it will stick.
    You're not trying hard enough. Just posting your code here (and unformatted, to boot!) and saying "fix this for me" isn't going to cut it. This is not rent-a-coder.

  • Evaluator.java won't compile due to issues with javax.tools.*

    * Evaluator.java
    * Created on January 23, 2007, 4:17 PM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package ObjectTools;
    import java.io.*;
    import java.net.*;
    import javax.tools.*;
    import java.lang.reflect.*;
    * Utilizes {@link java.lang.reflect} package
    * @author ppowell-c
    public abstract class Evaluator {
        public static boolean writeSource(final String sourcePath, final String sourceCode)
        throws FileNotFoundException {
            PrintWriter writer = new PrintWriter(sourcePath);
            writer.println(sourceCode);
            writer.close();
            return true;
        public static boolean compile(final String sourcePath) throws IOException {
            final JavaCompilerTool compiler = ToolProvider.defaultJavaCompiler();
            final JavaFileManager manager = compiler.getStandardFileManager();
            final JavaFileObject source =
                    manager.getFileForInput(sourcePath); /* java.io.IOException */
            final JavaCompilerTool.CompilationTask task = compiler.run(null, source);
            return task.getResult();
        public static final java.lang.Class loadExpression(final String path, final String className)
        throws MalformedURLException,
                ClassNotFoundException { /* java.net.MalformedURLException */
            final URLClassLoader myLoader = new URLClassLoader(new java.net.URL[] {
                new File(path).toURI().toURL()
            /* java.lang.ClassNotFoundException */
            return Class.forName(className, true, myLoader);
        public static java.lang.Object evalExpression(final Class test)
        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
            final Class[] parameterType = null;
            /* java.lang.NoSuchMethodException */
            final Method method = test.getMethod("expression", parameterType);
            final Object[] argument = null;
            Object instance = null;
            /* java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException */
            return method.invoke(instance, argument);
        public static Object eval(final String expression)
        throws FileNotFoundException, IOException, MalformedURLException,
                ClassNotFoundException, NoSuchMethodException, IllegalAccessException,
                InvocationTargetException {
            final Object result;
            final String path = "c:/";
            final String className = "ExpressionWrapper";
            final String sourcePath = path + className + ".java";
            writeSource(/* to */ sourcePath,
                    "public class " + className + "\n" +
                    "{ public static java.lang.Object expression()\n" +
                    "  { return " + expression + "; }}\n" );
            if(compile(sourcePath)) {
                final Class class_ =
                        loadExpression(/* from */ path, className);
                result = evalExpression(class_);
            } else {
                result = null;
            return result;
    }Produces compiler errors on javax.tools.ToolProvider along with nearly everything else in javax.tools to boot.
    I'm using J2SE 1.5.0 with NetBeans 5.5 so they all should be there. I'm following the example at http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht9Ht/evaluating-expressions-with-java since all I want to do is come up with a Java equivalent of "eval()", which I use in PHP whenever I need it.
    Help appreciated, I'm lost here.
    Thanx
    Phil

    How do you do the Java equivalent of eval()?The language provides no support for that.
    Reflection lets you call any method, where you
    specify that method's name as a string and go through
    a few other steps to build the proper Method object
    with the proper args.
    (http://java.sun.com/docs/books/tutorial/reflect/) It
    won't let you just evaluate Java source code as a
    script interpreter though. To do that, see
    www.beanshell.org. Jython and I think Ruby on Rails
    also give you scriptingin Java. Jython uses Python's
    syntax, but gives you access to your Java classes. I
    don't know ayhthing about RoR.I am going to look up PHP/Java myself as I know no Python right offhand (but probably could learn it in about 10,000 years). Tried to figure out reflection but couldn't figure out how to do what in PHP we do like this:
    $msg = eval('JButton ' . $nameArray[$i][0] . ' = new JButton("' . $nameArray[$i][1] . '");');

  • Sun image examples won't work

    I hope this is the right forum to post the question, I couldn't find a more proper forum for it.
    I have been trying to get some of the Sun examples working on my newly installed computer. They work as far as to compile and run, but the pictures involved will not show. The path is correct and the pictures are correct. It only uses javax.swing and java.awt which are working perfectly otherwise.
    So, everything seems to work, except for the pictures not showing. Did I miss a part of the installation (since it is Sun code, there couldn't be a problem with it and the compilation is flawless as is running it).
    I have also tried an old applet I made with pictures - it works perfectly.
    I use SDK 1.4.1.
    I have tried solving this for about 48 hrs now...

    found the solution (and I'm really not convinced by the quality Sun issues to the public)
    There are several errors:
    1. on linux the folder WEB-INF must(!) be named in capitals
    2. the line <!DOCTYPE ... is missing in web.xml
    3. the parameter value starting with d:\logs ... should be changed to /var/log ... on linux systems
    4. if you build webpad with ant in a system based on j2se 1.4 you should change the parameter in webpad.jnlp accordingly
    Given all these problems to bring up a first example what does the Sun promise "one click application" stands for?
    Rolf

  • Java 2 sdk 1.4.0 won't compile my code

    Hi,
    I just downloaded the lastest sdk 1.4.0 and tried compiling my project classes. But it throws a compilation error at the following import statement of a class in the current directory:
    import myEvent;
    Here my event is a class. in the current directory, and it has no package name.
    This import statement is part of an interface.
    Compiling the same with jdk1.3 is fine.
    If any of you have a clue as to what is going on here, please let me know.
    Or is this some kind of a bug in sdk 1.4.0 ?
    Thanks.
    Sangeetha

    I'll be darned - there it is, taken from http://java.sun.com/j2se/1.4/compatibility.html#source :
    The compiler now rejects import statements that import a type from the unnamed namespace. Previous versions of the compiler would accept such import declarations, even though they were arguably not allowed by the language (because the type name appearing in the import clause is not in scope). The specification is being clarified to state clearly that you cannot have a simple name in an import statement, nor can you import from the unnamed namespace.
    To summarize, the syntax
    import SimpleName;
    is no longer legal. Nor is the syntax
    import ClassInUnnamedNamespace.Nested;
    which would import a nested class from the unnamed namespace. To fix such problems in your code, move all of the classes from the unnamed namespace into a named namespace.

  • FtpClient client.delete("file") won't compile?

    Hello Fine People,
    I have this ftp program that is working, except for the delete command:
    import sun.net.ftp.*;
    import sun.net.*;
    String server = "192.168.0.0";
    String user = "me";
    String passwd = "mypassword";
    FtpClient client = new FtpClient();
    client.openServer(server);
    client.login(user, passwd);
    TelnetInputStream tis = null;
    client.binary();
    client.cd("Composites");
    tis = client.list();
    client.get("filename");
    client.delete("filename");
    This is roughly how it is. Without the last line, it compiles and runs fine. But when I add the client.delete line, it won't compile and gives this error:
    ImageTransfer.java:229: cannot resolve symbol
    symbol : method delete (java.lang.String)
    location: class sun.net.ftp.FtpClient
    client.delete("filename");
    Please help!
    - Logan

    Yes. The class you should be importing is, obviously, FTPClient. But don't waste your time trying to compile what is clearly just a code fragment example. The article lists several sources of FTP client software. Once you have chosen one package to evaluate, write your test program using the actual classes from that package, using its API documentation for guidance.

  • Infinite loop error after using Java Sun Tutorial for Learning Swing

    I have been attempting to create a GUI following Sun's learning swing by example (example two): http://java.sun.com/docs/books/tutorial/uiswing/learn/example2.html
    In particular, the following lines were used almost word-for-word to avoid a non-static method call problem:
    SwingApplication app = new SwingApplication();
    Component contents = app.createComponents();
    frame.getContentPane().add(contents, BorderLayout.CENTER);I believe that I am accidentally creating a new instance of the gui class repeatedly (since it shows new GUI's constantly and then crashes my computer), possibly because I am creating an instance in the main class, but creating another instance in the GUI itself. I am not sure how to avoid this, given that the tutorials I have seen do not deal with having a main class as well as the GUI. I have googled (a nice new verb) this problem and have been through the rest of the swing by example tutorials, although I am sure I am simply missing a website that details this problem. Any pointers on websites to study to avoid this problem would be appreciated.
    Thanks for your time-
    Danielle
    /** GUI for MicroMerger program
    * Created July/06 at IARC
    *@ author Danielle
    package micromerger;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.swing.JFileChooser;
    import java.lang.Object;
    public class MGui
         private static File inputFile1, inputFile2;
         private static File sfile1, sfile2;
         private static String file1Name, file2Name;
         private String currFile1, currFile2;
         private JButton enterFile1, enterFile2;
         private JLabel enterLabel1, enterLabel2;
         private static MGui app;
         public MGui()
              javax.swing.SwingUtilities.invokeLater(new Runnable()
                   public void run()
                        System.out.println("About to run create GUI method");
                        app = new MGui();
                        System.out.println("declared a new MGui....");
                        createAndShowGUI();
         //initialize look and feel of program
         private static void initLookAndFeel() {
            String lookAndFeel = null;
         lookAndFeel = UIManager.getSystemLookAndFeelClassName();
         try
              UIManager.setLookAndFeel(lookAndFeel);
         catch (ClassNotFoundException e) {
                    System.err.println("Couldn't find class for specified look and feel:"
                                       + lookAndFeel);
                    System.err.println("Did you include the L&F library in the class path?");
                    System.err.println("Using the default look and feel.");
                } catch (UnsupportedLookAndFeelException e) {
                    System.err.println("Can't use the specified look and feel ("
                                       + lookAndFeel
                                       + ") on this platform.");
                    System.err.println("Using the default look and feel.");
                } catch (Exception e) {
                    System.err.println("Couldn't get specified look and feel ("
                                       + lookAndFeel
                                       + "), for some reason.");
                    System.err.println("Using the default look and feel.");
                    e.printStackTrace();
         // Make Components--
         private Component createLeftComponents()
              // Make panel-- grid layout
         JPanel pane = new JPanel(new GridLayout(0,1));
            //Add label
            JLabel welcomeLabel = new JLabel("Welcome to MicroMerger.  Please Enter your files.");
            pane.add(welcomeLabel);
         //Add buttons to enter files:
         enterFile1 = new JButton("Please click to enter the first file.");
         enterFile1.addActionListener(new enterFile1Action());
         pane.add(enterFile1);
         enterLabel1 = new JLabel("");
         pane.add(enterLabel1);
         enterFile2 = new JButton("Please click to enter the second file.");
         enterFile2.addActionListener(new enterFile2Action());
         pane.add(enterFile2);
         enterLabel2 = new JLabel("");
         pane.add(enterLabel2);
         return pane;
         /** Make GUI:
         private static void createAndShowGUI()
         System.out.println("Creating a gui...");
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            JFrame frame = new JFrame("MicroMerger");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         //Add stuff to the frame
         //MGui app = new MGui();
         Component leftContents = app.createLeftComponents();
         frame.getContentPane().add(leftContents, BorderLayout.WEST);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
    private class enterFile1Action implements ActionListener
         public void actionPerformed(ActionEvent evt)
              JFileChooser chooser = new JFileChooser();
              int rVal = chooser.showOpenDialog(enterFile1);
              if(rVal == JFileChooser.APPROVE_OPTION)
                   inputFile1 = chooser.getSelectedFile();
                   PrintWriter outputStream;
                   file1Name = inputFile1.getName();
                   enterLabel1.setText(file1Name);
    private class enterFile2Action implements ActionListener
         public void actionPerformed(ActionEvent evt)
              JFileChooser chooser = new JFileChooser();
              int rVal = chooser.showOpenDialog(enterFile1);
              if(rVal == JFileChooser.APPROVE_OPTION)
                   inputFile2 = chooser.getSelectedFile();
                   PrintWriter outputStream;
                   file2Name = inputFile2.getName();
                   enterLabel2.setText(file2Name);
    } // end classAnd now the main class:
    * Main.java
    * Created on June 13, 2006, 2:29 PM
    * @author Danielle
    package micromerger;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    public class Main
        /** Creates a new instance of Main */
        public Main()
         * @param args the command line arguments
        public static void main(String[] args)
            MGui mainScreen = new MGui();
            //mainScreen.setVisible(true);
            /**Starting to get file choices and moving them into GPR Handler:
             System.out.println("into main method");
         String file1Name = new String("");
             file1Name = MGui.get1Name();
         System.out.println("good so far- have MGui.get1Name()");
        }// end main(String[] args)
    }// end class Main

    um, yeah, you definitely have a recursion problem, that's going to create an infinite loop. you will eventually end up an out of memory error, if you don't first get the OS telling you you have too many windows. interestingly, because you are deferring execution, you won't get a stack overflow error, which you expect in an infinite recursion.
    lets examine why this is happening:
    in main, you call new MGui().
    new MGui() creates a runnable object which will be run on the event dispatch thread. That method ALSO calls new MGui(), which in turn ALSO creates a new object which will be run on the event dispatch thead. That obejct ALSO calls new MGui(), which ...
    well, hopefully you get the picture.
    you should never unconditionally call a method from within itself. that code that you have put in the constructor for MGui should REALLY be in the main method, and the first time you create the MGui in the main method as it currently exists is unnecessary.
    here's what you do: get rid of the MGui constructor altogether. since it is the implicit constructor anyway, if it doesn't do anything, you don't need to provide it.
    now, your main method should actually look like this:
    public static void main( String [] args ) {
      SwingUtilities.invokeLater( new Runnable() {
        public void run() {
          MGui app = new MGui();
          app.createAndShowGUI();
    }// end mainyou could also declare app and call the constructor before creating the Runnable, as many prefer, because you would have access to it from outside of the Runnable object. The catch there, though, is that app would need to be declared final.
    - Adam

  • Can I get java/sun on my iPad2?

    The site I wish to have requires.  Java/sun.    Can I have that on my iPad2?      thanks.   [email protected]

    If you do want to run Java apps (or even applets), your best bet is subscribing to a 24/7 remote desktop service. It won't have the best responsiveness (after all, it's remote desktop) but you'll be able to run and operate(!) your stuff on your iPad.
    For example, AlwaysOnPC has JRE 1.7.0 installed, also freely usable by users.
    It's a highly popular service (see e.g. http://www.iphonelife.com/blog/87/how-you-will-want-watch-flash-only-videos-and- use-dynamic-flash-content for a review of it runnign Flash.) You can even try it for free on your desktop at http://www.alwaysonpc.com/signup.php . Note that there might be other, similar services as well.
    If, for some reason, the desktop version doesn't work for you, let me know if you have a Java app you'd like to be tested so that you can avoid having to pay for the iOS version of AlwaysOnPC so that you can test it.

  • Java 1.4.1 will compile clean but it wont run them using windows ME

    haveing trouble setting the path and the class path for windows me
    the code compiles clean but when i go to run it
    its wont run it comes up with a error of no class defination found
    thanks dkunze

    The Windows path is a set of pointers that Windows uses to locate programs that you execute, like javac.exe and java.exe. This setting is explained here:
    http://java.sun.com/j2se/1.4.1/install-windows.html
    Scroll down to: 5. Update the PATH variable
    (you should have already done this as part of the Java installation)
    The CLASSPATH is another set of pointers that is used by Java to find the files that you create and want compiled and/or run. This setting is explained here:
    Setting the Classpath:
    http://java.sun.com/j2se/1.4.1/docs/tooldocs/windows/classpath.html
    [NOTE: always start your classpath with ".;" which means the current directory. See my classpath, below]
    How Classes are Found:
    http://java.sun.com/j2se/1.4.1/docs/tooldocs/findingclasses.html
    Examples:
    This is my path
    PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\BATCH;C:\J2SDK1.4.1\BIN;C:\PROGRA~1\UTILIT~1;C:\PROGRA~1\WIN98RK
    This is my classpath
    CLASSPATH=.;C:\mjava;C:\mnrx;C:\NetRexx\lib\NetRexxC.jar;C:\j2sdk1.4.1\lib\tools.jar;C:\NetRexx\NrxRedBk

  • Images to Video (Sun Example doesn't work for me)

    Hi every one :)
    I'm trying to convert some jpg images into movie file. I saw the [Sun's example|http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/JpegImagesToMovie.html] , but when I try to execute I have a DataSink error:
    Cannot create the DataSink: javax.media.NoDataSinkException: Cannot find a DataSink for: com.sun.media.multiplexer.BasicMux$BasicMuxDataSource@c1f10e
    Failed to create a DataSink for the given output MediaLocator: foo.mov ¿There's another way to do it?
    P.S: Sorry for my english ;)

    darkskimmer wrote:
    The output MediaLocator, I create it with
    MediaLocator out = new MediaLocator("foo.mov");The error is creating out DataSink. No errors when creating the input stream of images...Which is why I told you specificlly...
    I believe the problem may be with how you're constructing your output MediaLocator... Check out their "main" method and see how they're converting their filenames into MediaLocators, and make sure you do that too. I can tell you, that's not how they do their output mediaLocators. They construct theirs with a "file://" prefix and a fully-rooted pathname. Check the code.
         if ((oml = createMediaLocator(outputURL)) == null) {
             System.err.println("Cannot build media locator from: " + outputURL);
             System.exit(0);
         }

  • Tomcat won't compile jsps if they are in any directory other than root

    I'm running a new instance of Tomcat, and can't get a simple jsp file to compile, if it's in any directory other than the root.
    The jsp is:
    <%@ page import="test.Simple" %>
    <%@ page contentType="text/html" language="java" %>
    <html>
    <body><%=Simple.makeText()%>
    </body>
    </html>
    and the Simple class is:
    package test;
    import java.util.Random;
    public class Simple {
    public static String makeText() {
    return String.valueOf(new Random().nextInt());
    When I place the jsp in the root directory, it works fine.
    When I place the jsp in any subfolder (eg: /debug/1b.jsp), I get the following error:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    Only a type can be imported. test.Simple resolves to a package
    An error occurred at line: 14 in the jsp file: /1b.jsp
    Generated servlet error:
    Simple cannot be resolved
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    Only a type can be imported. test.Simple resolves to a package
    An error occurred at line: 14 in the jsp file: /1b.jsp
    Generated servlet error:
    Simple cannot be resolved
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    Here's the server info:
    Server version: Apache Tomcat/5.5.25
    Server built: Sep 24 2007 11:31:18
    Server number: 5.5.25.0
    OS Name: Linux
    OS Version: 2.6.20.20-071008a
    Architecture: amd64
    JVM Version: 1.5.0_10-b03
    JVM Vendor: Sun Microsystems Inc.
    Using fedora core 6.
    I looked into the Tomcat work directory, and it looked as if the jsp was successfully converted to a java file. I'm not sure where to look, as all the settings are defaults.
    Any help is greatly appreciated. Thanks

    :D :D :D...
    My friend it'd be great idea if you can find google tutorial on TOMCAT/web application basics
    anyways coming back to your problem
    whenever,an application is deployed on tomcat a new folder is being created at the following location %CATILINA_HOME%/webapp/ with respect to application name.
    Therefore try to maintain an architecture like the one below if you programmin any web application.
    %CATILINA_HOME%/webapp/<applicationName>/(place all your .jsp files)
    -----------------%CATILINA_HOME%/webapp/<applicationName>/META_INF/(Place your mainfest files & context specific configuration files)
    -----------------%CATILINA_HOME%/webapp/<applicationName>/WEB_INF/ (Genrally used to save secured files which cannot be access directly and always make sure you prepare a web.xml file associated to the application)
    -----------------%CATILINA_HOME%/webapp/<applicationName>/WEB_INF/lib (place where all your .jar file libraries are being placed)
    -----------------%CATILINA_HOME%/webapp/<applicationName>/WEB_INF/classes (place where all your .class,resource files are being placed as the pacakage structure you have choosed in)
    If this doesnot work even if you ensuring everything's right.Reading through tutorials & speding time on finding resources by yourself would be a great idea.
    I hope there are no hard issue on this. :)
    REGARDS,
    RaHuL

  • Foreach loop in static block won't compile

    When I try to compile this:public class TestEnum
      private static String[] numerals =
          {"einz", "zwei", "drei", "vier"};
      static
        for (String n : numerals)
          // doesn't matter what's in here
      public static void main(String[] args)
    }I get this exception:An exception has occurred in the compiler (1.4.2-beta).
    java.lang.NullPointerException
        at com.sun.tools.javac.comp.Lower.visitArrayForeachLoop(Lower.java:2269)
        at com.sun.tools.javac.comp.Lower.visitForeachLoop(Lower.java:2242)
        at com.sun.tools.javac.tree.Tree$ForeachLoop.accept(Tree.java:559)
        at com.sun.tools.javac.comp.Lower.translate(Lower.java:1580)
        at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:51)
        at com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:131)
        at com.sun.tools.javac.tree.Tree$Block.accept(Tree.java:497)
        at com.sun.tools.javac.comp.Lower.translate(Lower.java:1580)
        at com.sun.tools.javac.comp.Lower.visitClassDef(Lower.java:1645)
        at com.sun.tools.javac.tree.Tree$ClassDef.accept(Tree.java:409)
        at com.sun.tools.javac.comp.Lower.translate(Lower.java:1580)
        at com.sun.tools.javac.comp.Lower.translate(Lower.java:1594)
        at com.sun.tools.javac.comp.Lower.translateTopLevelClass(Lower.java:2438)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:408)
        at com.sun.tools.javac.main.Main.compile(Main.java:523)
        at com.sun.tools.javac.Main.compile(Main.java:41)
        at com.sun.tools.javac.Main.main(Main.java:32)The same thing happens if I use foreach with a Collection instead an array. If I use an old-style for loop or Iterator in the static block, it compiles fine. I can also put the foreach loop in the main method, and it works. Is this a known bug?

    You guys rock. Thanks for finding this problem. I'll get it fixed.

  • Code won't compile - array

    This is my first in depth attempt to understand the code for enabling arrays. I THINK I have a fairly simple problem, but the code won't compile and NetBeans is telling me I'm missing a symbol &/or class, which I just don't get. Here is the code for the Inventory1 module as well as the main module - what am I not seeing?
    Inventory1 module
    import java.util.Scanner;
    import static java.lang.System.out;
    public class Inventory1
      //declare and initialize variables
      int[] itemNumber = new int [5];
      String[] productName = new String[5];
      int[] stockAmount = new int[5];
      double[] productCost = new double[5];
      double[] totalValue = new double[5];
      int i;
      //int i = 0;
      //initialize scanner
      Scanner sc = new Scanner(System.in);
      Inventory1 info = new Inventory1
    public void inventoryInput()
      while (int i = 0; i < 5; i++)
         out.println("Please enter item number: "); //prompt - item number
         info.itemNumber[i] = sc.nextInt(); // input
         out.println( "Enter product name/description: "); //prompt - product name
         info.productName[i] = sc.nextLine(); // input
         out.println("Quantity in stock: "); // prompt - quantity
         int temp = sc.nextInt(); // capture temp number to verify
         if( temp <=0 )
         { // ensure stock amount is positive number
             out.println( "Inventory numbers must be positive. Please" +
                 "enter a correct value." ); // prompt for correct #
             temp = sc.nextInt(); // exit if statement
         else info.stockAmount[i] = temp; // input
         out.println("What is the product cost for each unit? "); // prompt - cost
         double temp2 = sc.nextDouble();
         if( temp <=0 )
             out.println( "Product cost must be a positive dollar " +
                  "amount. Please enter correct product cost." );
             temp2 = sc.nextDouble();
         else info.productCost[i] = temp2;
      out.println( "We hope this inventory program was helpful. Thank you for " +
          "using our program." );
      } // end method inventoryInput   
    }main module
    public class Main {
      public static void main(String[] args) { //start main method
            Inventory1 currentInventory = new Inventory1(); //call Inventory class
            currentInventory.inventoryInput();
    }

    init:
    deps-jar:
    Compiling 1 source file to C:\Documents and Settings\Tammy\My Documents\School\JavaProgramming\Inventory\build\classes
    C:\Documents and Settings\Tammy\My Documents\School\JavaProgramming\Inventory\src\inventory\Inventory1.java:28: '(' or '[' expected
    public void inventoryInput()
    C:\Documents and Settings\Tammy\My Documents\School\JavaProgramming\Inventory\src\inventory\Inventory1.java:30: '.class' expected
    while (int i = 0; i < 5; i++)
    C:\Documents and Settings\Tammy\My Documents\School\JavaProgramming\Inventory\src\inventory\Inventory1.java:30: illegal start of type
    while (int i = 0; i < 5; i++)
    C:\Documents and Settings\Tammy\My Documents\School\JavaProgramming\Inventory\src\inventory\Inventory1.java:30: not a statement
    while (int i = 0; i < 5; i++)
    C:\Documents and Settings\Tammy\My Documents\School\JavaProgramming\Inventory\src\inventory\Inventory1.java:30: ';' expected
    while (int i = 0; i < 5; i++)
    5 errors
    BUILD FAILED (total time: 0 seconds)

  • Won't compile using v1.4.0

    I have downloaded the newer version, v1.4.0 of the runtime envrionment. I have set the path c:\j2re1.4.0.
    I'm able to execute my Java programs but not able to compile. Why is this?
    Thanks in advance.
    Ricardo
    [email protected]

    I'm able to execute my Java programs but not able to
    compile. Why is this?You have only downloaded the Java Runtime Environment, not the Java 2 Software Development Kit - try downloading the SDK...
    http://java.sun.com/j2se/1.4/download.html

  • JDeveloper 10.1.2.1 won't compile my code?

    Hi,
    I'm pretty new to JDeveloper, and Java in general.
    I've just downloaded and tried to run JDeveloper 10g (10.1.2.1.0, Build 1913) and I've having problems.
    When the application loads, I get a dialog message titled "Java Virtual Machine Launcher", with the message "Could not find the main class. Program will exit"
    JDeveloper then finishes loading.
    I've knocked up a quick JSP page, but it won't compile. I get the message "Internal compilation error, terminated with a fatal exception."
    Also, I've notived that if I go to Project Properties and try to look at Profiles->Development->Libraries, JDeveloper throws a NullPointerException.
    I've got JDeveloper 10.1.3 on my machine, and it has none of these problems?
    After looking around on the web, I'm thinking it might be a CLASS_PATH problem, but how can I confirm this, and how can I fix it?
    Any ideas on what is wrong would be appreciated?
    Thanks
    Thom

    Thanks thahn.
    That fixed the "Java Virtual Machine Launcher" error - I would never have thought spaces in the directory name could have caused this problem!
    The other problems remain though, so I still can't compile any code.

Maybe you are looking for

  • SRM SC in item in transfer I1111 status...no PO created

    Hi SRM gurus,                                                                                                                                                                                                                                           SR

  • How to backup data from a bad partition?

    Hi, My HDD in my Macbook Pro crashed due to a frequent uncontrollable on and off, I tried to boot into recovery mode but it won't let me mount the drive so that I can't repair permission, and I also fail to repair the disk neither not even target dis

  • Images in spry menus

    I'd like to use small images/icons in my vertical spry menu bar. this works ok, exept that the white separation line (border) between the menu items disappears in those spesific cells. The cells containing just text keep their white line, and I simpl

  • Error compliling HelloWorld.java

    Hi I'm running windows ME and I downloaded the Java 1.3v08 from this site and installed it like the manual said. I am having problems running the helloword program, it says > error: cannot read: Helloworld.java 1 error I'm a little discouraged now ca

  • IOS 4.2 just killed my iPod...I guess contacting support's my only option?

    So I just tried to update to 4.2 today, and iTunes sat for ages on a screen that said "verifying download with Apple" or something like that, with the iPod displaying an Apple with a progress bar that isn't filled at all... iTunes eventually timed ou