Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!

John Danek

Greenhorn
+ Follow
since Jun 12, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by John Danek

The only way I know isn't quite as simple as a properties file.

I manually wrote a .json file, then created a class that reads in the JSON using a BufferedReader. A stringBuilder takes the input from the file, then I make a JSONObejct out of it (using the net.sf.json.JSONObject package). Then, store these values into a map that contains another class that I wrote that actually hold the values. It takes a little bit of effort but ends up working quite well.
10 years ago
Thanks for your response!

GWT translates all of the Java source code in the package "client" to JavaScript. In my case, one of these classes uses bar. The project has the jar on its build path, and the jar has the source code in it. I'm just wondering if there's a way to tell GWT that "bar's source code is in bar.jar." That way, everyone implementing my jar in their GWT project doesn't have to manually create a client.bar subpackage and put the source code there.

Anyways, I'm currently trying to just send a RPC to a server where bar will be used, circumventing the need for compiling it in client, but this is rather tedious.

Does anyone know if my wished-for method is possible?
10 years ago
GWT
I have a GWT application, foo, that imports a jar (bar) I previously made that is solely Java. In the jar, I have a folder src/ in the top level that contains all of the source code. Yet, when I try to build foo, I get the error:

[java] [ERROR] Line 185: No source code is available for type bar; did you forget to inherit a required module?

Since bar is not a GWT application, I don't know what to do. I know using an "inherit" tag would help in foo's foo.gwt.xml, but bar isn't GWT. What to do to get it to work? I've scoured the web and this forum for a solution but have yet to find anything. Is there a way to tell the GWT compilier that the source is located in bar.jar's src/ folder?

Any help is greatly appreciated!
10 years ago
GWT
Ok, I fixed by using a Handler to setText, but now it appears my StopButton isn't working because if I hit Stop, then Start again, it crashed and the LogCat says


Could it be that because the Thread is sleeping, the setStopTracking() method isn't being called?

Thanks for you patience with all of this. It is greatly appreciated. Upon completion of this problem, I will begin trying to respond to beginners' questions on the forum for karma's sake (and the Java community's!).
10 years ago
Ok, I attempted rewriting my code into a single class thinking it may simplify/help identify what problems I have. Here is my class:




I still run into the same result. Upon hitting the Start Button, I get the same "The application has stopped unexpectedly" dialog with the Force Close button. Here is my LogCat log:


I think it may be a problem with mock location data? My SDK doesn't have a /data/misc/location/gps directory.

10 years ago
Ok, here is my log obtained from LogCat:

04-08 18:45:36.898: ERROR/vold(26): Error opening switch name path '/sys/class/switch/test2' (No such file or directory)
04-08 18:45:36.898: ERROR/vold(26): Error bootstrapping switch '/sys/class/switch/test2' (No such file or directory)
04-08 18:45:36.898: ERROR/vold(26): Error opening switch name path '/sys/class/switch/test' (No such file or directory)
04-08 18:45:36.898: ERROR/vold(26): Error bootstrapping switch '/sys/class/switch/test' (No such file or directory)
04-08 18:45:46.718: ERROR/BatteryService(51): usbOnlinePath not found
04-08 18:45:46.718: ERROR/BatteryService(51): batteryVoltagePath not found
04-08 18:45:46.718: ERROR/BatteryService(51): batteryTemperaturePath not found
04-08 18:45:46.728: ERROR/SurfaceFlinger(51): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
04-08 18:45:49.898: ERROR/EventHub(51): could not get driver version for /dev/input/mouse0, Not a typewriter
04-08 18:45:49.898: ERROR/EventHub(51): could not get driver version for /dev/input/mice, Not a typewriter
04-08 18:45:49.998: ERROR/System(51): Failure starting core service
04-08 18:45:49.998: ERROR/System(51): java.lang.SecurityException
04-08 18:45:49.998: ERROR/System(51): at android.os.BinderProxy.transact(Native Method)
04-08 18:45:49.998: ERROR/System(51): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
04-08 18:45:49.998: ERROR/System(51): at android.os.ServiceManager.addService(ServiceManager.java:72)
04-08 18:45:49.998: ERROR/System(51): at com.android.server.ServerThread.run(SystemServer.java:176)
04-08 18:45:50.008: ERROR/AndroidRuntime(51): Crash logging skipped, no checkin service
04-08 18:45:58.105: ERROR/ActivityThread(92): Failed to find provider info for android.server.checkin
04-08 18:45:59.385: ERROR/ActivityThread(92): Failed to find provider info for android.server.checkin
04-08 18:45:59.505: ERROR/ActivityThread(92): Failed to find provider info for android.server.checkin
04-08 18:46:02.405: ERROR/vold(26): Cannot start volume '/sdcard' (volume is not bound)
04-08 18:46:02.635: ERROR/MediaPlayerService(30): Couldn't open fd for content://settings/system/notification_sound
04-08 18:46:02.655: ERROR/MediaPlayer(51): Unable to to create media player
04-08 18:46:06.776: ERROR/AndroidRuntime(121): ERROR: thread attach failed
04-08 18:46:11.385: ERROR/ActivityThread(51): Failed to find provider info for com.google.settings
04-08 18:46:11.385: ERROR/ActivityThread(51): Failed to find provider info for com.google.settings
04-08 18:46:11.695: ERROR/AndroidRuntime(185): ERROR: thread attach failed
04-08 18:46:14.674: ERROR/gralloc(51): [unregister] handle 0x11f9b8 still locked (state=40000001)
04-08 18:47:26.208: ERROR/vold(26): Error opening switch name path '/sys/class/switch/test2' (No such file or directory)
04-08 18:47:26.208: ERROR/vold(26): Error bootstrapping switch '/sys/class/switch/test2' (No such file or directory)
04-08 18:47:26.208: ERROR/vold(26): Error opening switch name path '/sys/class/switch/test' (No such file or directory)
04-08 18:47:26.208: ERROR/vold(26): Error bootstrapping switch '/sys/class/switch/test' (No such file or directory)
04-08 18:47:35.898: ERROR/BatteryService(51): usbOnlinePath not found
04-08 18:47:35.898: ERROR/BatteryService(51): batteryVoltagePath not found
04-08 18:47:35.898: ERROR/BatteryService(51): batteryTemperaturePath not found
04-08 18:47:35.908: ERROR/SurfaceFlinger(51): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
04-08 18:47:39.158: ERROR/EventHub(51): could not get driver version for /dev/input/mouse0, Not a typewriter
04-08 18:47:39.158: ERROR/EventHub(51): could not get driver version for /dev/input/mice, Not a typewriter
04-08 18:47:39.248: ERROR/System(51): Failure starting core service
04-08 18:47:39.248: ERROR/System(51): java.lang.SecurityException
04-08 18:47:39.248: ERROR/System(51): at android.os.BinderProxy.transact(Native Method)
04-08 18:47:39.248: ERROR/System(51): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
04-08 18:47:39.248: ERROR/System(51): at android.os.ServiceManager.addService(ServiceManager.java:72)
04-08 18:47:39.248: ERROR/System(51): at com.android.server.ServerThread.run(SystemServer.java:176)
04-08 18:47:39.248: ERROR/AndroidRuntime(51): Crash logging skipped, no checkin service
04-08 18:47:45.545: ERROR/ActivityThread(92): Failed to find provider info for android.server.checkin
04-08 18:47:46.715: ERROR/ActivityThread(92): Failed to find provider info for android.server.checkin
04-08 18:47:46.805: ERROR/ActivityThread(92): Failed to find provider info for android.server.checkin
04-08 18:47:49.116: ERROR/AndroidRuntime(117): ERROR: thread attach failed
04-08 18:47:51.205: ERROR/vold(26): Cannot start volume '/sdcard' (volume is not bound)
04-08 18:47:51.375: ERROR/MediaPlayerService(30): Couldn't open fd for content://settings/system/notification_sound
04-08 18:47:51.375: ERROR/MediaPlayer(51): Unable to to create media player
04-08 18:47:54.064: ERROR/AndroidRuntime(162): ERROR: thread attach failed
04-08 18:47:57.514: ERROR/ActivityThread(51): Failed to find provider info for com.google.settings
04-08 18:47:57.514: ERROR/ActivityThread(51): Failed to find provider info for com.google.settings
04-08 18:49:14.114: ERROR/AndroidRuntime(196): Uncaught handler: thread main exiting due to uncaught exception
04-08 18:49:16.755: ERROR/AndroidRuntime(196): java.lang.NullPointerException
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at com.ist444.BlackBox.threadAlternative(BlackBox.java:139)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at com.ist444.BlackBox$1.onClick(BlackBox.java:66)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at android.view.View.performClick(View.java:2364)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at android.view.View.onTouchEvent(View.java:4179)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at android.widget.TextView.onTouchEvent(TextView.java:6540)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at android.view.View.dispatchTouchEvent(View.java:3709)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at android.os.Handler.dispatchMessage(Handler.java:99)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at android.os.Looper.loop(Looper.java:123)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at java.lang.reflect.Method.invokeNative(Native Method)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at java.lang.reflect.Method.invoke(Method.java:521)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-08 18:49:16.755: ERROR/AndroidRuntime(196): at dalvik.system.NativeStart.main(Native Method)
04-08 18:49:16.845: ERROR/dalvikvm(196): Unable to open stack trace file '/data/anr/traces.txt': Permission denied

There appears to be a lot of errors, but I can't make much sense of it.
10 years ago
I will do that as soon as I am done with class for the day and post it on here. Thanks for your help!
10 years ago
I added these to my manifest:



and I'm not exactly sure how to generate an exception log. I Googled "exception logging" but couldn't find anything appropriate.
10 years ago
Hello all,

I'm writing my first Android app (besides Hello World) and am running into a tricky runtime error. When I try getting the location data to update a TextView, the emulator Force Quits my program. I have been tweaking my code for two hours and can't figure out the problem. Here's the method in my code that is access the data:




Here is my constructor for this class, where my LocationManager and Location objects are made:


Does anyone have an idea as to what the correct code would look like? Many thanks.
10 years ago
I found a fix. By reducing the gridwidth, and changing the anchor to EAST, it now behaves properly. It was WEST previously.
11 years ago
A quick and (extremely) dirty way would be to first ask the user how many numbers s/he would like to enter, create an array of this size, and use a for loop to prompt with Input Dialogs. There's surely a much better way, though.
11 years ago
So I'm working on an app that has a JSplitPane. The right pane of the JSplitPane is a GridBagLayout ( I didn't choose it, the previous developers did). In it is a JTextField that is approx 10 characters wide.

*Problem* If I make the GridBagLayout pane larger, everything works fine. But if I shrink it by setting the JSplitPane divider to halfway, the text field completely disappears, even though there is obviously more space to the right of it. I've set the JTextField's gridwidth to be the maximum possible, but it still disappears. Any suggestions???
11 years ago
I found a quick fix to solving this problem. Here is the code inside my event handler:



I wish I could avoid making this new Thread, but it seems to work. If there is anyway to make the main thread call the method, I would love to know!
So my program consists of a JFrame with a Start button. Upon clicking the start button, I want my startSimulation() method to run, which resides in the class that created the frame. Current, I register startButton with startButtonListener. Within startButtonListener, I call the startSimulation() method in my SimulationController. But, this method has a ton of stuff to do (calculations, chart redraws, Thread.sleeps) and the frame hangs up for about 20 seconds.

I know this is because the startSimulation method is being called from within the Event Dispatch Thread. How can I make the main (default) Thread execute the startSimulation() method instead of the EventDispatchThread?

Thanks for your help, I am (obviously) new to the ideas of threading but have read up this morning in books. I would prefer to not create a new thread (since I already have the 2 I need).
Oh, thanks for the response. I think I came across the same cause as you.
11 years ago