Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
student:java:jar [2019/01/31 14:15] bernstdhstudent:java:jar [2022/11/07 21:33] – [Testing an Executable .jar File] stewarmc
Line 55: Line 55:
 ==== Testing an Executable .jar File ==== ==== Testing an Executable .jar File ====
  
 +If you just click/double-click on an executable ''%%.jar%%''  file and the code throws an exception you (typically) won't see  it. Hence, when testing it is often useful to run the application  from the command line. To do so, open a command shell (sometimes also called a terminal), change the working  directory to the directory that contains the ''%%.jar%%'' file (using the ''%%cd%%'' command),  and then execute the application as follows:
  
-If you just click/double-click on an executable ''%%.jar%%''  file and the code throws an exception you (typically) won't see  it. Hence, when testing it is often useful to run the application  from the command line. To do so, open a command shell, change the working  directory to the directory that contains the ''%%.jar%%'' file,  and then execute the application as follows:+|   java -jar //filename//.jar   |
  
 +If you get a message like the following:
  
 +<code>
 +Exception in thread "main" java.lang.UnsupportedClassVersionError
 +The program has been compiled by a more recent version of the Java Runtime (class file version XX.0), 
 +this version of the Java Runtime only recognizes class file versions up to YY.0
 +</code>
  
-|   java -jar //filename//.jar   | +it means that you need to update your version of Java. When doing so, you need to be careful because many systems have both the Java Runtime Environment (JRE) and the Java Development Kit (JDK) installed, and updating the one may not update the other. In Linux/OSX you can use ''%%which java%%'' and in MS-WIndows you can use ''%%where java%%'' to find the path to the Java interpreter. You can change the ''%%path%%'' environment variable (not the ''%%classpath%%'' environment variable) to change which Java interpreter is used (i.e., either the one installed with the JRE or the one installed with the JDK).
- +
  
 ==== Using Resources in a .jar File ==== ==== Using Resources in a .jar File ====