Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Java program runs on one computer but not on another?

I made a Java program on one of my three computers called Conversions. This is a very large program (.class file is 20kb) that uses the BreezySwing package to allow the user to convert values between different types of data types. If you are unfamiliar with Java simplification packages, you can read about BreezySwing here:

http://faculty.cs.wwu.edu/martin/Software%20Packag...

To make my program reliable to use, I created a batch file that would execute it and packaged it in a file folder that I could transport to other computers. The only thing I did not include in the file folder was a JDK download.

I was able to successfully copy the program to one of my other computers and have it run perfectly. There was only one minor problem with it. The problem was that during execution, Java would throw a NullPointerException error. However, the throwing of this error did not interfere with the functionality of the application; which still run fine. Both the design computer and the computer above had JDK version 7 installed.

Then I tried to put my program on a third computer (everything was exactly the same). However, when I attempted to run the application on this computer, Java throws a NullPointerException but does not allow the application to execute. In other words, the program does not work at all on this computer, it runs with runtime error on one, and runs perfectly on the original.

I find the problem very strange and I have no idea how to fix it. By commenting out certain parts of the source code of my program, I was able to determine that the error is being caused by the constructor, shown below:

//assume all variables have been declared before constructor

public Conversions(){

setTitle("Convert Application");

initialLbl = addLabel("Initial Value--->" ,1,1,1,1);

resultLbl = addLabel("Result--->" ,2,1,1,1);

initialFld = addDoubleField(0.00 ,1,2,1,1);

resultFld = addDoubleField(0.00 ,2,2,1,1);

convertBtn = addButton("CONVERT" ,3,2,1,1);

helpBtn = addButton("Help",4,2,1,1);

//repeated instantiation begins here...

tempLbl = addLabel("---Temperature---",6,1,1,1);

//begin placing temperature measures down rows

rbcelsius = addRadioButton("Celsius",7,1,1,1);

rbfahrenheit = addRadioButton("Fahrenheit",8,1,1,1);

rbkelvin = addRadioButton("Kelvin",9,1,1,1);

lengthLbl = addLabel("---Length---",10,1,1,1);

//begin placing length measures down rows

rbinch = addRadioButton("Inch",11,1,1,1);

rbmillimeter = addRadioButton("Millimeter",12,1,1,1);

rbfeet = addRadioButton("Feet",13,1,1,1);

rbyard = addRadioButton("Yard",14,1,1,1);

rbmeters = addRadioButton("Meter",15,1,1,1);

distLbl = addLabel("---Distance---",16,1,1,1);

//begin placing distance measures down rows

rbmile = addRadioButton("Mile",17,1,1,1);

rbkilometer = addRadioButton("Kilometer",18,1,1,1);

massLbl = addLabel("---Mass---",19,1,1,1);

//begin placing mass measures down rows

rbgram = addRadioButton("Gram",20,1,1,1);

rbounce = addRadioButton("Ounce",21,1,1,1);

rbpound = addRadioButton("Pound",22,1,1,1);

rbkilogram = addRadioButton("Kilogram",23,1,1,1);

NOTE: The entire constructor of my program is too large to place all of it here, so I have included most of it.

What is causing the problem with Java throwing NullPointerException? Is it the program syntax itself or is it the JDK or something else?

Update:

When I moved the application folder to the other computers, I changed everything to make sure that everything would work. If it was not correct, there would be a problem with the batch file; not the actual application. Therefore, I still have a problem.

2 Answers

Relevance
  • 1 decade ago
    Favorite Answer

    If it ran originally, you may have a problem with file paths.

    See, one time I hosted an applet on my website, and it never ran.

    I eventually found out that it was because originally stored in a folder named "source" and I stored it in a folder named "applets."

    Try opening the class file with notepad, and somewhere in it you should be able to see where the original file was.

    You need to get the naming right.

  • 5 years ago

    you may examine the different pc if it somewhat is have been given java with the help of employing the CLI and kind on any record. C:java -version There would desire to be readout version. Java would desire to be international and paintings on any record. in the adventure that your app is hassle-free and has one classification or jar. then basically use a CD or flash to circulate this java record. Or if many instructions then circulate all of them and/or any documents mandatory. you have got examined this out with a helloworld software, BTW.

Still have questions? Get your answers by asking now.