Duplicate :
|
|
Relates :
|
|
Relates :
|
Name: skT45625 Date: 08/09/2000 java version "1.3.0" Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C) Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode) Program text: package com.test; import java.util.*; public class BundleTest { public static void main (String args[]) { try { ResourceBundle resource = ResourceBundle.getBundle ( "bundle",Locale.getDefault()); if (resource !=null) { System.out.println("Bundle found."); } } catch (MissingResourceException mre) { System.err.println("bundle.properties " + " resource not found"); mre.printStackTrace(); } } } 1. write program to get ResourceBundle ( I put it in com.test package) 2. compile it 2. put it all in jar (jar cfvm tst.jar manifest.mf com bundle.properties) *.properties files, manifest.mf with indicating Main-Class manifest.mf source: Manifest-Version: 1.0 Main-Class: com.test.BundleTest 3. and run it with java -jar com.test.BundleTest if jar is in e.g. E:\test bundle found succesfully. if jar is in e.g E:\!test bundle is not found. and says that bundle resource not found java.util.MissingResourceException: Can't find bundle for base name bundle, locale us_us at java.util.ResourceBundle.throwMissingResourceException(Unknown Source ) at java.util.ResourceBundle.getBundleImpl(Unknown Source) at java.util.ResourceBundle.getBundle(Unknown Source) at com.test.BundleTest.main(BundleTest.java:7) (Review ID: 108166) ======================================================================
|