Taking Java a little lower

This post is not a help request.
It's just a sort of poll or curiousity question.
Would you agree to let java (by means of new api and jvm support of them, obviously) have lower level features?
Java VM works on every system, through native code, or better interfacing to a specific code of a specific Operating System.
That's why every os needs a dedicated vm.
Well, if that low level access is reached for operations like, drawing on the screen, playing sounds, io streams, networking, hidden memory management, and so on, what's the problem in giving java the possibility to do things like shutting down a system or formatting a unit (real formatting).
I know the latter is possible, in terms of file system manipulation.
But as for things like the first one? Every OS has a call which lets you shut it down.
Runtime.exec() is not cross-platform and it's not even always considered pure java.
JNI is not java (the part regarding native code).
What's the matter in having a System.shutdown()?
Or File.format(File root)?
Obviously such calls should be protected by a SecurityManager, as are other features in Java.
Java has a great API and you hardly feel the necessity for a closer contact with the hardware, but sometimes you do.
It'd get to be the most powerful, all-purposes, ultimate language.
Luckily, thanks to JNI and exec, you can find a way around most of those necessities, but it's not like the java I'd really like.
The 2 examples I've given are just the first things I could think of, but I'm sure many people would like to have other characteristics implemented.
Don't get me wrong.
I think Java is already the best all-purpose language around, and I really like it.
I like it so much I'd like I could do everything just using Java, no need for other external resources.
I just hope Sun will consider possibilities like those I mentioned.
So if you want to post your considerations, I'd really appreciate them, but please let's not start a flame out of it ^__^
Nobody criticized JAVA!!!

You seriously exepect the OS to let an application
tell it when to shut down? What happnes if you're
running this on some critical server thats running a
load of other apps?
I think you need to think your argument through a bit
more!I don't see any problem with that. Windows, Linux, MacOS,... native applications can easily shut the system down and nothing bad has ever happened...
As I said, that feature could be protected by security managing, meaning you need prehemptive user authorization.
Many native applications don't even let you authorize it.
Don't tell me you've never had a download manager or a cd-burner tool which had a check box like this : "Shut system down when operation is finished"...
So as you can see... it is accomplished regularily on every application. Java could easily be no exception.
I agrees to the idea but not the solution. instead I want to suggest > to have another package or development kit like j2me, j2ee for low
level hardware programming. Yes, why not. The problem though is not whether the APIs for that are standard or an expansion. The important thing should be the jvm accepting low level commands.
On SUN/OS (or Linux etc.) for example there is the shutdown command -
but it is available only with appropriate privileges, that is, for
the super user.YES, EXACTLY! On windows also, and probably on MacOS.
So, this is an example of low level feature available in every OS.
No portability issues in this one!
My guess why this does not yet exist is that either there are
technical difficulties (which you will probably discover when you
write the reference implementations), or there was no need for it yet
(which is a hint that it should better be an extension library
instead of part of the standard classes).I think the second one is the reason.
Probably there wouldn't be many tech diff. Java has much tougher features already there.
Very likely, Sun don't see specific low level access suitable in Java original conception.

Similar Messages

  • Can java be a low level programming language??*

    can java be a low level programming language??
    can anyone answer this question and explain it why?
    please please please...�
    [email protected]

    strike one: you are asking an obvious homework type program without showing any evidence of having done any work of your own first. Please show your work first. This isn't a homework service.
    strike two: you are cross posting here and in the "new to java forum". This irritates many of us to no end as we end up doing volunteer work to solve a problem only to find that its already been solved in another thread. So we've wasted our time for nothing. Don't do this.

  • Java .class files low-level (hex) editing?

    Hello, all!
    I have a problem:
    There is an application (namely a J2ME instant messanger for Nokia mobiles). It is a non-commercial application. But unfortunately, there is a bad bug in the application. It is not even a bug, it is more a feature - but it does not support Russian (cyrillic) characters encoding. Russian characters in all incoming messages are displayed with a kind of hierogliphs.
    I wrote to developers (and not only I did - I know at least 3 russian people who also wrote a developer about this) - but unsuccessful. Developer keeps silent.
    So what I decided is to fix the bug by myself :) By decompilation, e t.c.
    Unfortunally, the midlet is hard obfuscated :( So it took me some hours of reading obfuscated code, and now I see some ways which I must try to solve the problem. I think I must write a code which processes the desired String variables (Despite obfuscation, I can see which Strings to process to obtain effect), and inject this code somewhere to be executed, and from where it could reach the desired Strings.
    But the great problem is that obfuscated classes produce a lot of erroneus code, which can not be compiled back. So I decide to reject the decompilation at all, or at least of the big classes (where it is a lot of errors, which I can not correct manually).
    In some moments, the application stores the desired Strings in the java.lang.Hashmap. So if I could place my processing code into the Hashmap methods, then I could easily process what I need.
    Evidently, I can not edit the real basic java classes. But why not to make the applicaton using my class with identical functionality, instead of java.jang.Hashmap?
    My idea now is to edit the .class file of the midlet (yeah, edit with notepad), replacing all the references to "java/lang/Hashmap" or "java.lang.Hasmap" with "java/lang/Fuckmap" and "java.lang.Fuckmap".
    So did I (replaced it in norepad).
    I read the Sun's documentation about .class file structure, and it seems that nothing is against it. There is no encryption, no checksums, e t.c.
    Then I produced "Fuckmap" class this way:
    import java.lang.Hashmap;
    class Fuckmap extends Hashmap {}
    (compiled and preverified it of course)
    And placed it into java/lang folder inside the application jar.
    I instead of working properly, I get the "Application error - invalid constant pool entry"). What do I do wrong?

    2 lexzeus, mlk:
    I understood you.
    I jave just tried it, and used "jaga/util/Fuckmap" (jaga, not java). But still the same ("Invalid constant pool entry). I tried two times (maybe I could make something wrong?), both times took "clean" jar package, e t.c.
    Do you really think jav.alang.Hashmap should help now? I have ony little hope :(

  • Java big/little endian file support

    Hi, hope you can help,
    Firstly is Java bigendian or little endian or is this non manifest.
    I have a binary file that may exist either in big endian or little endian format.
    Is there support for reading differing byte orders, if not how do I go about reading either format.
    Many thanks in advance,
    Aaron

    Yes, Java has support for both byte orders.
    http://developer.java.sun.com/developer/JDCTechTips/2002/tt0507.html is an issue of JDC Tech Tips that discusses the use of java.nio.channels for this and has example code for writing and reading both orders.
    Many thanks.
    Sorry but there seems to be no way to award duke points a second time :(
    Aaron

  • Resolution seems a little low on big screen TV

    I shot some video at 1920x1080 (30 frames per sec). I used continuous lighting to light my subject. ISO was 640. The final results look really good. However, after burning to DVD using Encore to prepare the DVD, the movie looks a bit pixely. It does not appear noisy at all (because of the 640 iso), just a bit mid resolution. I have seen sharper, higher quality video on my big screen tv when I view a movie or TV. My big scrren TV is 50"
    Is this normal or have I exported the movie improperly from Premiere to get this issue? The export settings I used from Premiere were: Format:Quicktime, Preset:HD1080i 29.97, H.264, 48khz
    Thank you.

    Thank you for all the feedback. Really appreciate it. However, I am a newbie to Premiere and just discovered last night that to burn to DVD, I need to use Encore so I worked on learning that today. Most of the suggestions above are really a little over my head since I am so new to this. Basically, I shot HD video with 2 digital cameras - A Canon 7D and a Canon Rebel 3Ti. From there, I used Premiere to do all the editing of the video, added an intro movie at the beginning with a soundtrack from istock. I was a little unsure what to do once I had that completed. It did look quite good on my imac. From there I exported the entire thing as a Quicktime file, Preset:HD1080i 29.97, H.264, 48khz. Then I wanted to burn the file to a DVD so I could show my client. That is when I realized I just can’t burn away. So I did some research online and it looked like I needed to use Encore to do it. From there, I created a menu with buttons and it all seemed to work ok. When I reviewed the DVD on my big screen, that is when I noticed the slight resolution loss.
    Can one of you give me alittle direction (simple language for the newbie) as to what I should do? The advice above is just a bit over my head. I do not have a blue-ray burner by the way. I am also concerned about going to blue ray just because some people that will be viewing this video may not have blue ray.
    Thank you so much—I really appreciate your help.

  • I'm in desperate Need, please help....Taking .java back to .jsp?????

    Hello, I really made a mistake...and no one wants to start anything with those words.
    I was in the process of creating an ecommerse sight using html and jsp, when I did a really dumb thing and deleted my files... I thought I had backed them up on disk and was preparing to shift computers, and didn't want to leave anything behind on the computer.
    I might be ok, but I have a complex question.
    I was using tomcat to host my files locally. While using tomcat it compiled my files into .java and .class files. I have these files, as I didn't delete them before moving computers.
    This poses my question:
    Is there a way to reverse engineer the .java and .class files back into the original .jsp files????
    I still need to make a large amount of corrections to what I had, likewise I don't want to start all over from scratch..
    ANY help would be GREATLY appreciated.
    thank you very much.

    An idea...
    Couldn't you try to get and decompiled the .class files that Tomcat compiled from the servlet translated from the .jsp? This way, you would have lost your .jsp, but you could continue to work with the servlets or, if your motivated, you could cut and paste relevant parts of the servlets to new .jsp. That would surely be easier than rewrite all...

  • Java Socket on low bandwidths

    Hello!
    I am currently working on a project where we try to use Java technology (through Jini) over an HF radio link. That means we're working with bandwidths down to 75 b/s. And we are experiencing what we suspect is a timeout when we try to make a new Socket.
    What happends is we get a 'NoRouteToHostException: connection timed out', and it seems to us that this happends in the Socket constructor. That means we never get the chance to set the SO_TIMEOUT or other Socket parameters since the exception (seemingly) is thrown during Socket creation.
    This is mainly a problem on the lowest bitrate (75 bits per second), but we have also experienced this with 150 b/s. Not on a regular basis, though.
    We are about to write this off as being caused by some timeout in the Socket constructor which we have no chance to modify, but we would welcome any information that can help us understand this.

    75 b/sSo you get an effective rate of 9 bytes per second.
    That sounds like fun.
    Presume the IP packet size is 128 bytes And there is also a host lookup then it takes a minium of 4 packets. Which means 56 seconds to connect. And that is with no processing time. And no lost packets.
    Are you using a host name or just an IP? If the host name I believe you can do a lookup on that first and then use the IP. That would make a timeout less likely.

  • I'm trying to install iTunes in my Windows 7 64bits, the installer says it installed successfully (taking a really little time) and when I search for the program it isn't there. I tried with several versions of the program. What can I do?

    Help please!

    Help please, I'm thinking about buying and iPhone and I don't know what I'll do. It says there's no error but it doesn't install!

  • Require assistance on low level disk IO through Java.

    Hi
    I am looking for some java Api manual or java code for low level disk IO.
    Precise problem is, I am having minix image and a pen drive. I want to boot my pc from minix.
    In order to make pen drive bootable I need to write the image to sector 0 for which I have no idea how to do.
    Any info will be a gr8 help.
    Thanks
    Vineet.

    VineetArora wrote:
    Hi
    I am looking for some java Api manual or java code for low level disk IO.
    Precise problem is, I am having minix image and a pen drive. I want to boot my pc from minix.
    In order to make pen drive bootable I need to write the image to sector 0 for which I have no idea how to do.
    Any info will be a gr8 help.
    You can't. Give up now and choose a more suitable language for this project.

  • Java.lang.IllegalThreadStateException - Trying to restart a Thread

    Hi, since I'm new to this forum, I'll start right off with a question.
    I'm trying to create an application, which guides the user trough several windows. In the first window there is some user input, and frame2 opens. frame2 then opens, depending on user input, frame1 (restart the cycle) or frame3.
    I tried this with Threads, a Thread for each frame to keep things less complicated (less messy etc.).
    Now the problem:
    When I try to restart frame1, I get the error "java.lang.IllegalThreadStateException". The source code:
    public class Sss extends Thread
        (public variables that can be changed or used by other classes)
        public static frame1 a = new frame;
        public static void main(String[] args)
            a.start();
    public class frame1 extends Thread implements ActionListener
        //several public static variables/object for the frame etc.      
        public frame1()
        public void run()
              //create the frame, add objects, add actionlisteners
        public void actionPerformed(ActionEvent e)
            //several buttons redirected to different methodes
        //several methodes
        public void end() //is called in a method
          frame2 p = new frame2();
           p.start();
        } This still works, but then:
    public class frame2 extends Thread implements ActionListener
    //several public static variables/object for the frame etc
        public frame2()
        public void run()
    //create the frame, add objects, add actionlistener
          public void end()
                if(a)          //boolean a is true or false
                    frame1 q = new frame1();
                    q.start();
                else
                     frame3 w = new frame3();
                     w.start();
    public void actionPerformed(ActionEvent e)
            //several buttons redirecting to different methods
    } In the end method, "q.start();" gives the error. Am I doing something wrong? Shouldn't I be using Threads at all, should I try something different(what, how?)
    I'm a student from The Netherlands, 18 years old, and I'm going to study "technische informatica" (don't know what it is in English, sorry, but it involves programming ;)). I've worked with Java on a low profile the last two years, learning & exploring, my most difficult application made is an ChatProgram (client/server based, in a local network). So this gives you my level in programming a little bit, I hope ;)
    If someone is able to help me, please.
    Niek

    Niekfct wrote:
    Well it's not actually helping me, you're posting things what I've already found out. And I can't imagine you've put a lot of time in such an answer. But if someone DOES post a usefull answer, i will be grateful for it. So if someone can help me, please.
    And with help I mean, maybe an other way to do this, maybe a way to slightly adjust the existing classes to make it work.
    (Please don't look at me as if I'm some lazy boy who can't figure anything out by himself. I'm trying to help others, and I hope others will help me.)Uhm, how are you trying to help others with this?
    Also, how is pointing out that the path you are currently taking is pointless and a waste of time not helpful. At the very least it should cause you to stop even attempting to continue along that path, and prompt you to take a step back and try to look at the problem from another angle.
    Jeesh, instead you just, essentially, say "Shut up! I know what I'm doing!". Well, that sounds like you really wanted help. Sounded more like you wanted confirmation, not help.
    In any case, why don't you simply get rid of all references to threads, and simply change all but the main frame to JDialogs?
    From what I can I see, of what you have posted here, that should be more than enough.
    Just make sure, of course, that you don't mix your business logic into your GUI. Which you must have be doing currently, since a GUI class, in and of itself, has absolutely no reason to need it's own thread. It wouldn't help anything regardless of how you looked at it.

  • General: Java has become so vast ... is there a way to join it all.

    This is a generic question and nothing to do with coding, but all to do with Java.
    Personally I am starting to find Java a little bit to vast. For example you have J2SE, J2EE, JDO, then you have Hibernate, Struts, Spring, SWT, and some others which I still don't know of.
    Now (Since I have have much time to waist) I started thinking the difference between the Java Development Environments and Visual Studio.Net (Just to make it a point, I prefer Java, mine is just comparision please).
    When installing VS.net you have all the technologies (.net framework) there at one go. With Java is a little bit different. You install the JDE which may come whit it's own jdk, and then you can continue adding on (Jars) for what else you want to add in your project.
    Now I know that this situation comes from the fact that Java has many different open source projects, while .net does not. However would it be great if there was an IDE that comes with everything (as much as I know eclipse does not, if yes please tell me).
    If this is not possible, is there a place which tells you all the technologies available out there in one list, whith just one click download?
    Again I am not critising Java in any way, I am saying is there a way to make it simpler to program with? I understand the answer can be a blunt no, but why no, or why yes?
    Thanks :)

    and I am sure that projects
    like Eclipse will reach VS.net.
    My view is that it already has.To make my Eclipse copy similar to VS.net (not like it) I had to install a plugin called Lomboz! Reaching is one thing .. overpassing is another, and that is what java needs (from an IDE perspective) to bring fresh programmers to it, programmers that are not coding in Java coz school demands it, but because they prefer it over other languages.
    To simplify the complex you have to streamline. Each
    "simplification" basically lowers the skills needed
    to perform a task. At the lower end just about
    "anybody" can program. This means that also "anybody"
    will program.I totaly agree with you, making things simpler will mean that any one will learn how to program with that language. VB6.0 was just an example of that. However VB6.0 became also the most popular tool when developing fast rapid applications just because of it's simplicity, which mostly came from the IDE.
    So Java programming will be simpler, don't worry. The
    question is will you be satisfied with the salary?hmmm ... I never am to say the truth :) I agree also with this point guess if things get simpler then salaries will go down ... too many people knowing the same thing will mean a lot for companies to choose from.
    However (I can be totally wrong here) doesn't Java (as a language) run the risk of no longer being used by "Most" of the industry just because there are few developers knowing it inside out??
    To download it you do need a bit of time. The J2ME PP
    reference implementation is over 30MB. The CLDC /
    MIDP stuff is over 25MB. That's a lot of download,
    but it's probably used by no more than 5% of Java
    programmers. I suspect Visual Studio .NET is
    primarily distributed on CD - I know the beta I have
    kicking around somewhere was.Well, my last version of VS.net came on 7 CD's and it took GB's out of my hard disk space. Having said that, I believe that in todays time Space and download time are no longer a big issue. But there are people having Dial-Up down there!! so one way I would solve this out would be to make a more interactive download page in which it lets you determine what packages to have in your installation.

  • Java Pinging question

    Hi
    First if all, I hope this is the correct place to post such question..My apologies if that is the case.
    Anyway, like a lot of other people, I'm trying to implement a Ping mechanism in Java. I have read some of the available suggestions and none really solves the problem.
    One idea is to use JNI...this is against what I am trying to achieve as I want to implement a pure java ping.
    Which means, I don't want to use a Native call such as Runtime.exec("cmd") neither;
    Thus, I have tried the following, to use a sock connection to get ping that way:
    public static long getPing(String url, int port, int timeout) throws IOException{
              long start, end;
              long pingTime = 0;          
              SocketAddress sockaddr = new InetSocketAddress(url, port);          
              Socket socket = new Socket();
              start = System.currentTimeMillis();
              socket.connect(sockaddr);
              end = System.currentTimeMillis();
              socket.close();
                    pingTime = end - start;
              return pingTime;
         }My quesiton is, even though this implementation seems to work, it does not provide a good solution as opening a socket is different from sending a icmp packet and thus doesn't really qualify as a ping. Is there a better approach to this problem?
    I know Java is not low level enough to deal with such things, is there no way around it?
    I hope have have explained myself here. I would be greatful for any ideas, or suggestions. It is a bit frustrating, as I have been scratching my head for the whole day trying to get this little thing solved.
    Thanks you for your time,
    Bigboy A

    Sjasja,
    Thank you for your reply.
    I'm actually trying to implement a pure java webcrawler, as I'm learning about java networking at the moment. While the crawler is working fine..I also need to include more functionalities, for example while crawling the program could obtain statistics on quality of service of a particular site - possibly through ping time of a give domain. By quality of service, I want to include things such as the quality of the network between my machine and the host, for example the response time of a site (the ping), the success rate of udp packets etc, and possibly more..sort like a network diagnose function.
    HTH
    Thanks alot

  • Java as a Web Technology is Living on Borrowed Time

    Java’s change in market status from a viable web technology to what it is nowundesirable legacy codeis astonishing. Oracles recent patch for Javas zero-day flaw puts one more nail in the coffin. Zero-day status is assigned to flaws that are currently being exploited by hackers, and for which there is no available fix. A little […]
    Read More
    This topic first appeared in the Spiceworks Community

    Well to be brutally honest, I think you'd be better off sticking with Flash if this is a critical project... it would be a great exercise for learning Java, but would probably take w-a-y-y-y-y-y more effort than doing a similar multimedia presentation in flash.
    (I haven't used Director, so can only talk about Flash here) - as you know, Flash is really a very powerful authoring tool that allows the user to do very complex animations very easily, whereas Java is a lower-level programming language that is infinitely more flexible, but comparatively more developer-intensive when it comes to producing user interface stuff. Java might be a viable option if you have to do stuff that flash can't, like very complex interactivity, or pulling info from a database etc (although maybe Flash 5 can even talk to databases now??? I don't know)
    You can get tools to help you build Java user interfaces using "drag & drop" methods, and these tools will automatically generate the code for you, but (a) this means you're not really learning java, and (b) flash would still be less labor-intensive (and probably more impressive to your end users)
    In summary - I'm not knocking Java or Flash - I love 'em both; it's just that Flash is better suited for certain things, and Java is better suited for others...
    PS - nice website, but Portfolios shouldn't have an apostrophe before the "s" ;-)

  • Database in Java!!

    I'm in class and taking Java right now. Te teachers project is to pint out a list of employees using drawStrings. To me That doesn't have any real teachings or learning involved. So what I wanted to do is create a database(MicroSoft Works only one I have) fill it with the info and then pull it in. Below are my two errors and what they are. I'm using JDK 1.1.8 should I be using another one. If anyone can help I would Appreciate it. Thanks!!!
    import java.sql.*;
    import javax.swing.*;     //error one package not found import java.awt.event.*;
    import java.awt.*;
    import java.util.*;
    import java.lang.*;
    public class conxtest extends JFrame{ // error # 2superclass not found
    private JTable DataTable;
    private Connection Database;
    public conxtest() {
    String url = "jdbc:odbc:customers";
    String userID = "John";
    String password = "settle";
    Statement DataRequest;
    ResultSet Results;
    try {
              Class.forName( "sun.jdbc.odbc.jdbcOdbcDriver");
                   Database =
                        DriverManager.getConnection(url,userID,password);
    catch (ClassNotFoundException error) {
         System.err.println("Cannot connect to the database." + error);
              System.exit(1);
    catch (SQLException error){
         System.err.println("Cannot connect to the database" + error);
              System.exit(2);
    try {
              String query = "Select * FROM customer";
              DataRequest = Database.createStatement();
              Results = DataRequest.executeQuery (query );
              DisplayResults (Results );
              DataRequest.close();
    catch (SQLException error ) {
         System.err.println("SQL eroor." + error);
         System.exit(3);
         setSize (500,200);
         show();
    private void DisplayResults (ResultSet DisplayResults)throws SQLException
         boolean Records = DisplayResults.next();
         if (!Records ) {
         JOptionPane.showMessageDialog( this, "End of Data.");
         setTitle ( "Process Completed");
         return;
              setTitle ("CUSTOMER NAMES");
                   Vector ColumNames = new Vector();
                   Vector rows = new Vector();
         try {
              ResultSetMetaData MetaData = DisplayResults.getMetaData();
              for (int x =1; x <= MetaData.getColumnCount(); ++x)
              ColumnNames.addElement (MetaData.getColumnName(x));
         do {
              rows.addElement (DownRow(DisplayResults, MetaData ));
              } while ( DisplayResults.next());
              DataTable = new JTable ( rows, ColumnNames );
              JScrollPane scroller = new JScrollPane ( DataTable);
              getContentPane().add(scroller, BorderLayout.Center);
                   validate();
              catch (SQLException error ) {
                   System.err.println("Data display error." + error);
                   System.exit(4);
         private Vector DownRow (ResultSet DisplayResults, ResultSetMetaData MetaData)
         throws SQLException
         Vector currentRow = new Vector();
              for (int x = 1; x <= MetaData.getColumnCount(); ++x)
              switch ( MetaData.getColumnType (x)){
              case Types.VARCHAR :
              currentRow.addElement(DisplayResults.getString(x));
                   break;
              return currentRow;
              public void Disconnect()
              try {
              Database.close();
              catch (SQLException error){
              System.err.println("Cannot break connection." + error);
                   System.exit(5);
              public static void main ( String args[])
              final conxtest link = new conxtest();
              link.addWindowListener (
                   new WindowAdapter() {
              public void windowClosing(WindowEvent WinEvent )
              link.Disconnect();
              System.exit (0);
              

    Thanks, After I posted this I loaded a CD with a book I got Called JAVA Game Programming with a higher version now I have three new errors I'm killing my eyes trying to figure them out. If you or someone else can offer help thanks.
    import java.sql.*;
    import javax.swing.*;                                   
    import java.awt.event.*;
    import java.awt.*;
    import java.util.*;
    import java.lang.*;
    import java.applet.Applet;
    public class conxtest extends JFrame{
    private JTable DataTable;
    private Connection Database;
    public conxtest() {
    String url = "jdbc:odbc:customers";
    String userID = "Jason";
    String password = "settle";
    Statement DataRequest;
    ResultSet Results;
    try {
              Class.forName( "sun.jdbc.odbc.jdbcOdbcDriver");
                   Database =
                        DriverManager.getConnection(url,userID,password);
    catch (ClassNotFoundException error) {
         System.err.println("Cannot connect to the database." + error);
              System.exit(1);
    catch (SQLException error){
         System.err.println("Cannot connect to the database" + error);
              System.exit(2);
    try {
              String query = "Select * FROM customer";
              DataRequest = Database.createStatement();
              Results = DataRequest.executeQuery (query );
              DisplayResults (Results );
              DataRequest.close();
    catch (SQLException error ) {
         System.err.println("SQL eroor." + error);
         System.exit(3);
         setSize (500,200);
         show();
    private void DisplayResults (ResultSet DisplayResults)throws SQLException
         boolean Records = DisplayResults.next();
         if (!Records ) {
         JOptionPane.showMessageDialog( this, "End of Data.");
         setTitle ( "Process Completed");
         return;
              setTitle ("CUSTOMER NAMES");
                   Vector ColumName = new Vector();
                   Vector rows = new Vector();
         try {
              ResultSetMetaData MetaData = DisplayResults.getMetaData();
              for (int x =1; x <= MetaData.getColumnCount(); ++x)
              ColumnName.addElement (MetaData.getColumnName(x));//symbol columnName not resolved
         do {
              rows.addElement (DownRow(DisplayResults, MetaData ));
              } while ( DisplayResults.next());
              DataTable = new JTable ( rows, ColumnName);//symbol columnName not resolved
              JScrollPane scroller = new JScrollPane ( DataTable);//symbol Center not resolved
              getContentPane().add(scroller, BorderLayout.Center);
                   validate();
              catch (SQLException error ) {
                   System.err.println("Data display error." + error);
                   System.exit(4);
         private Vector DownRow (ResultSet DisplayResults, ResultSetMetaData MetaData)
         throws SQLException
         Vector currentRow = new Vector();
              for (int x = 1; x <= MetaData.getColumnCount(); ++x)
              switch ( MetaData.getColumnType (x)){
              case Types.VARCHAR :
              currentRow.addElement(DisplayResults.getString(x));
                   break;
              return currentRow;
              public void Disconnect()
              try {
              Database.close();
              catch (SQLException error){
              System.err.println("Cannot break connection." + error);
                   System.exit(5);
              public static void main ( String args[])
              final conxtest link = new conxtest();
              link.addWindowListener (
                   new WindowAdapter() {
              public void windowClosing(WindowEvent WinEvent )
              link.Disconnect();
              System.exit (0);
         

  • I need some help with my java game using applets, CAN SOMEBODY PLEASE HELP

    Hi,
    I am in the process of creating a RPG program using Java. I am not very experienced with java, however the problem i am currently facing is something i can't seem to figure out. I would like to draw a simple grid where a character (indicated by a filled circle) moves around this grid collecting items (indicated by a red rectangle). When the character moves on top of the grid with the item, i would like it to disappear. Right now i am not worrying about the fact that the item will reappear after the character moves away again, because sometimes, when the character moves over the item, nothing happens/another item disappears. i have been at this for 4 days and still cannot figure out what is goign on. can somebody please help me? it would be most appreciated.
    Thanks
    PS if i needed to send you my code, how do i do it?

    Thank you for replying.
    The thing is, I am taking java as a course, and it is necessary for me to start off this way (this is for my summative evaluation). i agree with you on the fact, however, that i should go in small steps. i have been doing that until this point, and my frustration caused me to jump around randomly for an answer. I also think that it may just be a bug, but i have no clue as to how to fix it, as i need to show my teacher at least a part of what i was doing by sometime next week. Here is my code for anybody willing to go through it:
    // The "Keys3" class.
    import java.applet.*;
    import java.awt.*;
    import java.awt.Event;
    import java.awt.Font;
    import java.awt.Color;
    import java.applet.AudioClip;
    public class Keys3 extends java.applet.Applet
        char currkey;
        int currx, curry, yint, xint;
        int itmval [] = new int [5],
            locval [] = new int [5],
            tempx [] = new int [5], tempy [] = new int [5],
            tot = 0, score = 0;
        boolean check = true;
        AudioClip bgSound, bgSound2;
        AudioClip hit;
        private Image offscreenImage;
        private Graphics offscreen;     //initializing variables for double buffering
        public void init ()  //DONE
            bgSound = getAudioClip (getCodeBase (), "sound2_works.au");
            hit = getAudioClip (getCodeBase (), "ah_works.au");
            if (bgSound != null)
                bgSound.loop ();
            currx = 162;
            curry = 68;
            setBackground (Color.white);
            for (int count = 0 ; count < 5 ; count++)
                itmval [count] = (int) (Math.random () * 5) + 1;
                locval [count] = (int) (Math.random () * 25) + 1;
            requestFocus ();
        public void paint (Graphics g)  //DONE
            resize (350, 270);
            drawgrid (g);
            if (check = true)
                pickitems (g);
                drawitems (g);
            g.setColor (Color.darkGray);
            g.fillOval (currx, curry, 25, 25);
            if (currkey != 0)
                g.setColor (Color.darkGray);
                g.fillOval (currx, curry, 25, 25);
            if (collcheck () != true)
                collision (g);
            else
                drawitems (g);
        } // paint method
        public void update (Graphics g)  //uses the double buffering method to overwrite the original
                                         //screen with another copy to reduce flickering
            if (offscreenImage == null)
                offscreenImage = createImage (this.getSize ().width, this.getSize ().height);
                offscreen = offscreenImage.getGraphics ();
            } //what to do if there is no offscreenImage copy of the original screen
            //draws the backgroudn colour of the offscreen
            offscreen.setColor (getBackground ());
            offscreen.fillRect (0, 0, this.getSize ().width, this.getSize ().height);
            //draws the foreground colour of the offscreen
            offscreen.setColor (getForeground ());
            paint (offscreen);
            //draws the offscreen image onto the main screen
            g.drawImage (offscreenImage, 0, 0, this);
        public boolean keyDown (Event evt, int key)  //DONE
            switch (key)
                case Event.DOWN:
                    curry += 46;
                    if (curry >= 252)
                        curry -= 46;
                        if (hit != null)
                            hit.play ();
                    break;
                case Event.UP:
                    curry -= 46;
                    if (curry <= 0)
                        curry += 46;
                        if (hit != null)
                            hit.play ();
                    break;
                case Event.LEFT:
                    currx -= 66;
                    if (currx <= 0)
                        currx += 66;
                        if (hit != null)
                            hit.play ();
                    break;
                case Event.RIGHT:
                    currx += 66;
                    if (currx >= 360)
                        currx -= 66;
                        if (hit != null)
                            hit.play ();
                    break;
                default:
                    currkey = (char) key;
            repaint ();
            return true;
        public boolean collcheck ()  //DONE
            if (((currx == tempx [0]) && (curry == tempy [0])) || ((currx == tempx [1]) && (curry == tempy [1])) || ((currx == tempx [2]) && (curry == tempy [2])) || ((currx == tempx [3]) && (curry == tempy [3])) || ((currx == tempx [4]) && (curry == tempy [4])))
                return false;
            else
                return true;
        public void collision (Graphics g)
            drawgrid (g);
            for (int count = 0 ; count < 5 ; count++)
                if ((currx == tempx [count]) && (curry == tempy [count]))
                    g.setColor (Color.darkGray);
                    g.fillOval (currx, curry, 25, 25);
                else if ((currx != tempx [count]) && (curry != tempy [count]))
                    g.setColor (Color.red);
                    g.fillRect (tempx [count], tempy [count], 25, 25);
        public void drawitems (Graphics g)
            for (int count = 0 ; count < 5 ; count++)
                g.setColor (Color.red);
                g.fillRect (tempx [count], tempy [count], 25, 25);
        public void pickitems (Graphics g)
            check = false;
            for (int count = 0 ; count < 5 ; count++)
                if (locval [count] <= 5)
                    tempy [count] = 22;
                else if (locval [count] <= 10)
                    tempy [count] = 68;
                else if (locval [count] <= 15)
                    tempy [count] = 114;
                else if (locval [count] <= 20)
                    tempy [count] = 160;
                else if (locval [count] <= 25)
                    tempy [count] = 206; //this determines the y-position of the item to be placed
                if (locval [count] % 5 == 0)
                    tempx [count] = 294;
                else if ((locval [count] == 1) || (locval [count] == 6) || (locval [count] == 11) || (locval [count] == 16) || (locval [count] == 21))
                    tempx [count] = 30;
                else if ((locval [count] == 2) || (locval [count] == 7) || (locval [count] == 12) || (locval [count] == 17) || (locval [count] == 22))
                    tempx [count] = 96;
                else if ((locval [count] == 3) || (locval [count] == 8) || (locval [count] == 13) || (locval [count] == 18) || (locval [count] == 23))
                    tempx [count] = 162;
                else if ((locval [count] == 4) || (locval [count] == 9) || (locval [count] == 14) || (locval [count] == 19) || (locval [count] == 24))
                    tempx [count] = 228;
        public void drawgrid (Graphics g)  //DONE
            g.drawRect (10, 10, 330, 230); //draws the outer rectangular border
            int wi = 10; //width of one square on the board
            int hi = 10; //height of one square on the board
            for (int height = 1 ; height <= 5 ; height++)
                for (int row = 1 ; row <= 5 ; row++)
                    if (((height % 2 == 1) && (row % 2 == 1)) || ((height % 2 == 0) && (row % 2 == 0)))
                        g.setColor (Color.gray);
                        g.fillRect (wi, hi, 66, 46);
                    else /*if (((height % 2 == 0) && (row % 2 == 1)) || ((height % 2 == 0) && (row % 2 == 0)))*/
                        g.setColor (Color.lightGray);
                        g.drawRect (wi, hi, 66, 46);
                        g.setColor (Color.lightGray);
                        g.drawRect (wi, hi, 66, 46); //drawn twice to make a shadow effect
                    wi += 66;
                wi = 10;
                hi += 46;
            } //this draws the basic outline of the game screen
    } // Keys3 class

Maybe you are looking for

  • Wildcard SSL Certificates with MFE?

    Is anyone using a wildcard SSL certificate on their mail server when using Mail for Exchange on assorted Nokia E Series mobiles please? We currently use a straight SSL cert and MFE works with no problem, however I've been looking into getting a singl

  • How to display millisecond along with hh:mm:ss

    Hi folks! This has the reference to the answer given by Jagruti to my previous question, which has the same subject of this. In my program i've used localtime function which is declared in /usr/include/time.h to get seconds. Then I used the macros 'S

  • Java Servlet/Html link problem

    Hi, I have been using the Java servlet to create the html code itself using the PrintWriter.I would like to know if it possible to input ALL the code into - PrintWriter out=null; out.println("<Html><Body>the entrie html code</Body></Html>"); or must

  • Menu "clear recent history is not actif? how to make actif?

    how to make actif menu clear recent history?

  • Bluetooth trouble on MacBook, Blackberry involved too

    This is a complete mystery to me...my bluetooth application is no longer fun ctioning. Network port configurations do not recognise the bluetooth hardware. I checked the Apple hardware menu and could not find my bluetooth hardware. I don't remember d