My java program runs fine even if i don't specify access specifier of class

Hi,
My java program runs fine even if i don't specify access specifier of class as public .
Then why do they say that atleast one class should be specified as public.
please help.

public access specifier is the default access
specifier
so if you dont give the access specifier before the
class name it is not wrong.I think that you are wrong. The default specifier is package or "package-private".
See here:
http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html
Message was edited by:
petes1234

Similar Messages

  • Process name representation in a LINUX machine for a JAVA program running..

    Hi,
    We are using an Intel machine loaded with Red Hat Linux 7.2 OS to run JAVA programs. We have a requirement to calculate the CPU and MEMORY usage for each JAVA program running. Unfortunately when a java program is run say "java ESR" and we run a ps -ef | grep -i java, it is shown as hkumar 2847 2799 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2874 2847 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2875 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2876 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2877 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2878 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2879 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2880 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2881 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2882 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2883 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2884 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2885 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    instead of the actual name of the program ie. ESR.
    Does anybody know why this happens? Is there a way out to ensure that "ps -ef | grep java" gives the actual name of the java program being RUN?
    Thanks in advance,
    Harish

    You have less chance to identify which programm that VM instance is running right now.
    But you could (as we do) keep track of your programs if you save the process-id when you start the program.
    We need this to shut down running java batch programs but you could find out the used system resources with this way as well...

  • How to execute unix command from the Java program running on Windows

    Hello,
    I need to
    1. Execute a unix shell script from a Java program running on the Windows.
    2. I also need to capture the output of this shell script in my program.
    Please suggest me how to achieve this.
    Thanks in Advance.

    Hi...
    Something is missing here
    If you want to execute a shell script in windows that not posible unless you find or develop a unix shell script parser for windows.
    But if you are trying the execute a unix shell script on a remote unix computer from your java program running on a windows platform you can do that by logging on to the UNIX terminal which is running on port 23 I think.
    You can test this using telnet tool on windows
    just type on command prompt
    telnet <ip of the unix pc> <port number this case 23>
    you should get the unix terminal. If that works you can do the same through java or you can directly conect to port 23 of that pc using sockets that way your program will be platform independant

  • Execute Unix command from Java program running on windows

    Hello,
    I need to write a java program that fetches file count in a particular unix machine directory. But java program will be running on windows machine.
    The program should execute unix list command and fetch the output of that command.
    Can anyone help me on this?
    Thanks.

    Hi there,
    I had a similiar problem, though years ago. It was to have a java program execute any other. Lately, I've had to have a java program running on a unix machine execute a shell script. Entirely two different scenarios. I'm not sure what you will need for your app, but look into this:
    Java Native Interface for executing C/C++ code.
    C/C++ Code for launching the program you need to run.
    java.lang.Runtime(?).exec(....)
    With a combination of that stuff, you can make a launcher for any os that has Java running on it, and with Runtime, you can exec() pretty near any sort of unix shell or app command you'd like.
    Good luck.
    Tim

  • Why does my program run fine in highlight execution, but not normally?

    When I highlight execution, the program runs fine, but when I run the program normally, nothing happens. (I believe the program is stuck at the initialize cam vi). If someone could help me out, I'd be very thankful
    Attachments:
    intensity10.vi ‏139 KB

    The first troubleshooting technique I did was to add several "waits" throughout the program, particularily with the loops. I learned the problem was actually with the hardware itself and the camera mode. The camera must take an empty frame before it can store the image, thus the for loop needed to be replaced with a while loop.
    However, after fixing the program using boolean logic, 2 of the buttons disappear on my front panel during use (which I will have to further troubleshoot). Thank you!
    Attachments:
    intensity11.vi ‏158 KB

  • Is there any way to check another Java program running status?

    HI. I want to write a Java program on hand-set but my program seems needs lots of resources and if there is another Java program running on the same hand-set simultaneously, my program will slow down. So, I want to check if there is another Java program is running on the hand-set, my program will show a message to user reminding user to close another program first.
    Is there any way to do so?

    On most recent devices, the application is not terminated but paused by using phone functions, and can be reactivated from the aplication management software. The javax.microedition.midlet package documentation is quite specific, if a tad obscure, about the MIDlet lifecycle and the role of the MIDelt methods vis-a-vis the AMS.
    {color:#0000ff}http://java.sun.com/javame/reference/apis/jsr037/javax/microedition/midlet/package-summary.html{color}
    Parenthetically, I've never been able to figure out how resumeApp should be used, nor have I seen this method invoked in any of the samples that come with the WTK, but I haven't gone through all of them.
    I believe the still-in-progress MIDP3 will make it possible to have MIDlets that share the screen with native apps and which can be minimized and restored.
    db

  • Memory leak? amd 64 bit using 1.4.2_03 program runs fine on other computers

    I have a program that runs fine on a red hat linux desktop and a pentium 1.6ghz xp pro laptop but on my amd 64 bit 3400+ xp pro desktop after ~20 seconds it slows to a crawl. i was originally using j2sdk1.4.2_04 but noticed this was not available for download anymore so i switched to j2sdk1.4.2_03 but have the same problem. my laptop is using j2sdk1.4.2_03. im not sure what the red hat linux machine is using. this is a starfield simulator and when it starts to slow all the stars turn gray and its like the drawLine is not working right either. anyone have any ideas? code is below
    import java.awt.*;
    import java.awt.event.WindowListener;
    import java.awt.event.WindowEvent;
    import java.util.*;
    import javax.swing.*;
    import java.io.*;
    class StarfieldWindowListener implements WindowListener
    public void windowActivated( WindowEvent e ) {}
    public void windowClosed( WindowEvent e ) {}
    public void windowClosing( WindowEvent e )
    System.exit(0);
    public void windowDeactivated( WindowEvent e ) {}
    public void windowDeiconified( WindowEvent e ) {}
    public void windowIconified( WindowEvent e ) {}
    public void windowOpened( WindowEvent e ) {}
    public class StarfieldSimulator
         public static void main (String args[])
              JFrame frame = new JFrame ("Starfield Simulator");
              frame.getContentPane ().setLayout (new BorderLayout ());
              if (args.length == 0) frame.getContentPane ().add (new Starfield (500));
              else frame.getContentPane ().add (new Starfield (Integer.parseInt (args[0])));
    frame.addWindowListener(new StarfieldWindowListener());
              frame.setSize (1024, 768);
              frame.show ();
    class Point3D
         public double x, y, z;
    public float r, g, b;
    public Color c;
         public Point3D (double x, double y, double z)
    Random random = new Random ();
              this.x = x;
              this.y = y;
              this.z = z;
    r = random.nextFloat();
    g = random.nextFloat();
    b = random.nextFloat();
    c = new Color( r, g, b );
    class Starfield extends JComponent
         protected boolean first;
         protected Point3D points[][];
         protected Random random;
         private int trail = 20;
    private double rot = .0005, co = Math.cos( rot ), si = Math.sin( rot );
         public Starfield (int numPoints)
    //RepaintManager repaintManager = RepaintManager.currentManager(this); repaintManager.setDoubleBufferingEnabled(false);
              first = true;
              random = new Random ();
              points = new Point3D[numPoints][trail];
              for( int y = 0; y < numPoints; ++y )
                   for( int x = 1; x < trail; ++x )
                        points[y][x] = new Point3D( 0, 0, 0 );
              for (int index = 0; index < numPoints; index++)
                   points[index][0] = new Point3D ((random.nextDouble () - 0.5) * 2.0, (random.nextDouble () - 0.5) * 2.0, (random.nextDouble () - 0.5) * 2.0);
         public void paint (Graphics g)
    //DebugGraphics g = new DebugGraphics(g1);
    int i;
              int halfWidth = getWidth () / 2;
              int halfHeight = getHeight () / 2;
              g.setColor (Color.black);
              g.fillRect (0, 0, getWidth (), getHeight ());
              int pointsLength = points.length;
              for (int index = 0; index < pointsLength; index++)
                   for( i = trail - 1; i >= 1; --i )
                        points[index] = points[index][i - 1];
    if( points[index][0].z <= 0.0 )
    while (points[index][0].z <= 0.0) points[index][0] = new Point3D ((random.nextDouble () - 0.5) * 2.0, (random.nextDouble () - 0.5) * 2.0, (random.nextDouble () - 0.5) * 2.0);
    points[index][0].r = random.nextFloat();
    points[index][0].g = random.nextFloat();
    points[index][0].b = random.nextFloat();
    for( i = 1; i < trail; ++i )
    points[index][i].x =points[index][i].y = points[index][i].z = 0;
    g.setColor (points[index][0].c);
                   for( i = 0; i < trail; ++i )
                        points[index][i].x = points[index][i].x * co - points[index][i].y * si;
                        points[index][i].y = points[index][i].y * co + points[index][i].x * si;
    int sx1, sy1, sx2, sy2;
    sx1 = (int) ((points[index][0].x * halfWidth) / ((points[index][0].z) * 10.0)) + halfWidth;
    sy1 = (int) ((points[index][0].y * halfHeight) / ((points[index][0].z) * 10.0)) + halfHeight;
    if( points[index][(trail - 1)].z == 0 )
    g.drawRect( sx1, sy1, 1, 1 );
    else
    sx2 = (int) ((points[index][(trail - 1)].x * halfWidth) / ((points[index][(trail - 1)].z + .0005 * (trail - 1)) * 10.0)) + halfWidth;
    sy2 = (int) ((points[index][(trail - 1)].y * halfHeight) / ((points[index][(trail - 1)].z + .0005 * (trail - 1)) * 10.0)) + halfHeight;
    g.drawLine( sx1, sy1, sx2, sy2 );
    points[index][0].r = (float) Math.min ( points[index][0].r + .00005, 1.0 );
    points[index][0].g = (float) Math.min ( points[index][0].g + .00005, 1.0 );
    points[index][0].b = (float) Math.min ( points[index][0].b + .00005, 1.0 );
    points[index][0].c = new Color( points[index][0].r, points[index][0].g, points[index][0].b );
                   points[index][0].z -= 0.0025;
    try {
    Thread.sleep(1);
    } catch (InterruptedException e) {
    e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    repaint();

    doesnt ANYONE have an answer?? please?Apparently not. If the answer involves us typing in your program, understanding it, debugging it, etc., hey, we all have jobs, too. We can answer specific questions ("How do I do <some specific task>?" or "I tried this and that <specific task> but ran into <specific problem>"). But we don't have all day to debug everyone's programs.
    * First of all, use the code formatting markup around your code (See the Formatting Help link).
    * Secondly, tell us what you have tried - have you looked at your Task Manager and recorded your program's size? Compare it on the machines where it runs well, and the one where it doesn't.

  • Java program running as win32-service

    Hi,
    I am running Java programs as Win32-Services on a Windows-Cluster with Windows 2000 Service Pack 4. I have written a Wrapper program in C which runs as a Service and creates a JVM. Normally this works fine but now I have on one cluster the problem that I don't have any output in the Console of the Service. All the output which is written with System.out.println to the console just does not appear.
    And if I read input from the console I get the following exception:
    -E-2005-02-15 16:04:44.734: java.io.IOException: The handle is invalid
    at java.io.FileInputStream.readBytes(Native Method)
    at java.io.FileInputStream.read(FileInputStream.java:194)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:220)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:277)
    at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:408)
    at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:450)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:182)
    at java.io.InputStreamReader.read(InputStreamReader.java:167)
    at java.io.BufferedReader.fill(BufferedReader.java:136)
    at java.io.BufferedReader.readLine(BufferedReader.java:299)
    at java.io.BufferedReader.readLine(BufferedReader.java:362)
    at at.co.systema.gf.util.ConsolePrompt$ConsoleTask.run(ConsolePrompt.java:98
    Does anybody have experience with running java programs as Win32 services ?
    Ingo

    Your application needs to be able to run without System.in or System.out
    There is no console for a service.
    Replace System.out with a logger. If you need input you need to write a client which sends the commands to the service.

  • Photoshop CS5 lags, but other programs run fine

    I installed the CS5 Creative Suites onto my eMachines E525 latpop. It came with 2 GB of RAM but I upgraded it to 4 GB.
    Harddrive is at 165GB free of 220GB.
    Processor is Intel Celeron CPU 900 @ 2.20 GHz, 2194Mhz, 1 Core, 1 Logical Processor
    All the other programs in the suite run fine. The only problem I'm having is with Photoshop. Whenever I use a tool, it lags. If I use any of the shape tool, as I drag it out, it lags. Same goes for the brush tool and any other tool that I use.  Efficiency is at 100% whenever I have a document open, but the tools  still drag. Even on a blank 500x500 document at 72 dpi lags.
    I've looked through the Optimize Photoshop Perfomance page, and I've done all that I know I can do, and it still lags.
    I turned off OpenGL Drawing, Let Photoshop use 2385MB (70%). I've changed it to let it use more, but that doesn't help.
    I installed Photoshop, InDesign, Illustrator, Dreamweaver, and Flash Catalyst from the Suite.
    I also have Norton 360.
    Is Norton causing Photoshop to be slow or is it something else?
    Is there anything I can do to fix the lag or do I need to make more upgrades to my laptop?

    What display interface is in that laptop (e.g., a nVidia model, Intel model, etc.)?
    The OpenGL implementation in the video driver can have a drastic effect on the performance.  Have you tried the following as a diagnostic?
    Edit - Preferences - Performance.
    Uncheck [ ] Enable OpenGL Drawing.
    Close and restart Photoshop.
    If after doing the above you see the lag problem eliminated, you might want to check with your laptop maker (or in rare cases the video interface maker) to see if any updated display drivers have been released.  Many OpenGL problems have been corrected in recent driver releases.
    Make sure you re-enable OpenGL after changing drivers to see if the highest performance is now available to you.
    You could also try keeping OpenGL enabled but going into the [Advanced Settings...] and changing to Basic mode.
    -Noel

  • Make Java program run on other pc's

    Good afternoon,
    So I have this Java program compiling on my pc through NetBeans.
    Now if I want this program to run on other pc's on its own (without NetBeans or any other program), preferably through a GUI, do I have to convert it to a JAR file? How does this exactly works out?
    Thanks for your help.

    alley wrote:
    So I have this Java program compiling on my pc through NetBeans.And Netbeans does it using the JDK. it is always the JDK, no matter how many tools you wrap around it on top. You don't need Netbeans to run your stuff either, it is merely a development convenience that Netbeans provides you.
    >
    Now if I want this program to run on other pc's on its own (without NetBeans or any other program)Impossible - you need at least a compatible Java runtime.
    , preferably through a GUIYou mean by double clicking on the program icon through the OS?
    , do I have to convert it to a JAR file? That would be an easy way yes - an executable jar to be more precise
    How does this exactly works out?Netbeans builds the jar automatically, just check out the folders of your project to find it. If you set a main class in the project properties, it is even an executable jar. Double click it and if the Java runtime is properly setup (which tends to be the case when it installs succesfully, but many people manage to screw it up in a way I can't imagine anyway), it will run.
    For further guidance, check the online netbeans manual and research executable jars.

  • Java programs runs in eclipse but no of errors on command line

    I have a strange problem. I made program that runs fine in eclipse IDE but when I try to compile it using 'javac', it raises a lot of errors. All of same kind with location different.
    The error is ' cannot find symbol '. Symbol: class AllegroGraph.... ' cannot find symbol '. Symbol: variable AGPaths....
    ' cannot find symbol '. Symbol: class valueSetIterator...................
    How can I remove this error as this error is definitely not letting me to specify a bat file to run this program as the way I am advised in my other thread about bat file.

    Are you using 3rd party API for your project? It looks like you are using APIs from [this site|http://www.franz.com/agraph/allegrograph/].
    To compile from the command prompt, you have to specify the 3rd party API (jar files) as classpath. Like so...
    javac -cp <3rd party>.jar *.java

  • Program running fine in Debug mode but failing in direct execution

    Hi All,
    I am facing a peculiar problem, I have created a report that create STO then Delivery and then Shipment one after one. I have used BAPI to do so. If STO creation is successful then Create Delivery and if delivery creation is also successfull then create Shipment.
    When I run this program by pressing execute button it is only creating STO and coming out ,but if I run it in Debug mode I get all the three( STO, Delivey,Shipment). Since it run fine in debug so I can't found where the problem is.
    Can any one help???
    Regards
    Hemant

    Hi guys,
    A learning for me .... how important WAIt parmeter is in commit work .. Initially i have not set WAIT paramater in commit BAPI to X due to this further processing.. Delivery and Shipment creation was failing in direct execution ... as after STO creation I was reding EKPO and that was failing in direct execution , but in backgroung everything was ok.
    Thanks for your time.
    Cheers
    Hemant

  • Can a java program run as a system process?

    Hi,
    I need to know if a java program can be run as a system process. I don't want it to be run as a user process. Is there any way at all?

    Tomcat is such a program.
    If you want to write a program that runs like a daemon (Unix) or a Windows service (Windows), use the Jakarta Daemon Framework (no, it is not an Indonesian devil) that was used to write Tomcat. Check http://jakarta.apache.org/commons/daemon/

  • Make java program run on a scheduler

    I have a java program that currently runs as a cron job at specific intervals. I want to run it at smaller intervals not allowed by cron, like every minute. I want it to wake up, check it's work load, process it, and then sleep for a minute...and do this over and over again. What code can I insert into my java program to accomplish this.

    All you need is to have all of your Threads go back to sleep when there is no work to be done so that your application doesn't consume any resources while it doesn't have any work to do.
    If you want your application to go back to sleep for one minute when it has emptied a JobQueue, all you need is to use Thread.sleep(60000); inside the piece of code which is looking for the work load.
    Overall, this approach is much better than a cron job, since you could end up with concurrency issues with the cron job. Consider ending up with a workload which requires more than a minute to be processed... Before you can get it done, there's a new instance of your program which tries to get the same jobs done at the same time! You could get a lot of headaches with this :P
    Message was edited by:
    Dalzhim

  • Making a java program run in Windows and Linux via web applets

    Hello, this is my first post at java.sun.com
    I made an application in Linux, using Jbuilder Fundation 2005. I used the JDBC MySQL connector for Linux, and I used Mandriva as a distro. What I did is a program that allows me to connect remotely to my server, in order to update the news.
    However I want to create an applet, in which you could click a button, and the main frame of the program will load. I have no idea how to do this, since this program runs great on my linux machine, and from what I know it uses the MySQL JDBC jar that's installed on my machine, and a lot of classes from the Jbuilder program directory.
    How could I upload this program to a webpage (with the applet idea that I mentioned earlier) so that both Linux and (especially) Windows clients could use it?
    It will also be nice to know how to create a .jar file that has all of the required classes in it, I know that Jbuilder enterprise does this, but I don't have that version or plan buying it.
    Thanks in advance

    Put the jre folder from your JDK install in your app folder.ok, but in this way he doesn't have to download jre
    but I have to add it to the app folder so that an
    application large just some kilobytes would become
    some megas bigger... unless I have misunderstood what
    you're suggesting me of course.Yeah, that's the downside. However, 17 MB isn't very large by todays standards.
    jre\javaw -cp <your classpath> <your main class><your classpath> is the class i need to be run's path
    or my classpath?
    jre\javaw has to be written like this or preceeded by
    the path of jre directory?As long as you point 'start in' to the correct directory, I don't believe you have to worry about that. That path you have there isn't quite right (neither was mine) but I think you've got that under control.
    You can give anm explicit path, then you can have different users with different start-in values and store their properties there automatically.

Maybe you are looking for