Josh Diamond

Greenhorn
+ Follow
since Jul 15, 2017
Merit badge: grant badges
For More
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
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Josh Diamond

Getting errors in my XML files lines 3-9 e.g. cannot resolve symbol @dimen/activity_horizontal_margin



Also getting errors here from lines 3-6 e.g. line 3 cannot resolve symbol @dimen/activity_horizontal_margin
6 years ago
Building my first android game and am getting "cannot resolve symbol R" (lines 31-39) on several java files for instance my EnemyShip class. Using Android Studio ver 2.3.3. I have enemy ship png's in my resources folder so don't really know why I'm getting this error.

6 years ago
worked it out. It's because charAt is 0 index based so  you have to do charAt(i-1).
6 years ago
Any ideas why I'm getting this error? Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 64 at java.lang.String.charAt(String.java:658) at ReverseString.main(ReverseString.java:8)



6 years ago
Thanks for spotting my stupid mistake but when I run it it just shows a black screen which then says GameOver in the middle. Can someone else try running it and see if the same thing happens?
6 years ago
Is that what you mean by running appletviewer from the SnakeGame directory?
6 years ago
Got this:

C:\Users\Joshu\Downloads\Snake game> appletviewer com/zetcode/SnakeGame.html
load: class com.zetcode/Snake not found.
java.lang.ClassNotFoundException: com.zetcode.Snake
       at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:219)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
       at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:152)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
       at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:634)
       at sun.applet.AppletPanel.createApplet(AppletPanel.java:799)
       at sun.applet.AppletPanel.runLoader(AppletPanel.java:728)
       at sun.applet.AppletPanel.run(AppletPanel.java:378)
       at java.lang.Thread.run(Thread.java:748)
6 years ago

Tony Docherty wrote:

BTW I can't see how you could have compiled the code as is, am I right in thinking you downloaded the class files along with the Java files?



No I compiled it normally using javac
6 years ago
Changed the directory structure and still getting this:

C:\Users\Joshu\Downloads\Snake game\com\zetcode>appletviewer SnakeGame.html
load: class com.zetcode/Snake not found.
java.lang.ClassNotFoundException: com.zetcode.Snake
       at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:219)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
       at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:152)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
       at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:634)
       at sun.applet.AppletPanel.createApplet(AppletPanel.java:799)
       at sun.applet.AppletPanel.runLoader(AppletPanel.java:728)
       at sun.applet.AppletPanel.run(AppletPanel.java:378)
       at java.lang.Thread.run(Thread.java:748)
6 years ago
Trying to run an applet using appletviewer and getting this in cmd:

c:\Users\Joshu\Downloads\Snake game\package com.zetcode>appletviewer SnakeGame.html
load: class com.zetcode/Snake.class not found.
java.lang.ClassNotFoundException: com.zetcode.Snake.class
       at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:219)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
       at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:152)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
       at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:634)
       at sun.applet.AppletPanel.createApplet(AppletPanel.java:799)
       at sun.applet.AppletPanel.runLoader(AppletPanel.java:728)
       at sun.applet.AppletPanel.run(AppletPanel.java:378)
       at java.lang.Thread.run(Thread.java:748)


This is what is in the directory I'm calling appletviewer from:

Directory of c:\Users\Joshu\Downloads\Snake game\package com.zetcode

18/07/2017  14:21    <DIR>          .
18/07/2017  14:21    <DIR>          ..
18/07/2017  13:44               187 Board$1.class
18/07/2017  13:44             1,143 Board$TAdapter.class
18/07/2017  13:44             4,654 Board.class
18/07/2017  12:49             5,629 Board.java
18/07/2017  13:44               468 Snake$1.class
18/07/2017  13:44               782 Snake.class
18/07/2017  12:50               683 Snake.java
18/07/2017  14:24               221 SnakeGame.html
              8 File(s)         13,767 bytes
              2 Dir(s)  435,662,188,544 bytes free

This is the html file:

<!DOCTYPE html>
<html>
<head>
<title>Snake Game</title>
</head>
<body>
<APPLET code="com.zetcode/Snake." width="300" height="180"> Sorry your browser isn't able to run java applets
</APPLET>
</body>
</html>

This is the Snake.java file:




This is the board.java file:


Any ideas?
6 years ago

Norm Radder wrote:What program are you using to execute the applet?
It works for me in AppletViewer.



Using appletviewer.
6 years ago
Trying to run this applet and am getting this error message: Exception in thread "pool-1-thread-1" java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")

I'm created the html file for the applet and in addition added the comment //<applet code = "NotPong.class" width = 400 height = 200> </applet> at the top of the applet. I've also tried to edit the java.policy file with the policy tool by adding  permission java.lang.RuntimePermission "modifyThreadGroup";

There shouldn't be anything wrong with the applet itself because it's from a book but I have no idea why it is not running. Any ideas?



6 years ago