Results 1 to 11 of 11
- 09-02-2012, 01:15 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 71
- Rep Power
- 0
I'm trying to display a sphere, but I get an error.
Hi, I installed Java3D but it's not behaving correctly. Here's my code:
However all I get is a bunch of access restriction errors:Java Code:import com.sun.j3d.utils.geometry.*; import com.sun.j3d.utils.universe.*; import javax.media.j3d.*; import javax.vecmath.*; public class ThreeDball { public static void main(String[] args) { SimpleUniverse uni = new SimpleUniverse(); BranchGroup group = new BranchGroup(); Sphere ball = new Sphere(0.5f); uni.addBranchGraph(group); Color3f color = new Color3f(2,2,0); BoundingSphere bounds = new BoundingSphere(new Point3d(0,0,0), 1000); Vector3f direction = new Vector3f(5, -6, -10); DirectionalLight light = new DirectionalLight(color, direction); light.setInfluencingBounds(bounds); group.addChild(light); group.addChild(ball); uni.getViewingPlatform().setNominalViewingTransform(); } }
I know I can change Eclipses behavior to just give a warning instead of an error with regards to access restrictions, and doing that removes all the errors, but I get this runtime error:Description Resource Path Location Type
Access restriction: The constructor SimpleUniverse() is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeDball.java /ThreeDball/src line 9 Java Problem
Access restriction: The type SimpleUniverse is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeDball.java /ThreeDball/src line 9 Java Problem
Access restriction: The type SimpleUniverse is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeDball.java /ThreeDball/src line 9 Java Problem
Access restriction: The type Color3f is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\vecmath.jar ThreeDball.java /ThreeDball/src line 15 Java Problem
Access restriction: The type BranchGroup is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dcore.jar ThreeD.java /ThreeD/src line 12 Java Problem
Access restriction: The method addBranchGraph(BranchGroup) from the type SimpleUniverse is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeDball.java /ThreeDball/src line 13 Java Problem
Access restriction: The method addChild(Node) from the type Group is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dcore.jar ThreeD.java /ThreeD/src line 13 Java Problem
Access restriction: The type Sphere is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeDball.java /ThreeDball/src line 11 Java Problem
Access restriction: The constructor ColorCube(double) is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeD.java /ThreeD/src line 13 Java Problem
Access restriction: The type ColorCube is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeD.java /ThreeD/src line 13 Java Problem
Access restriction: The constructor Sphere(float) is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeDball.java /ThreeDball/src line 11 Java Problem
Access restriction: The type Sphere is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeDball.java /ThreeDball/src line 11 Java Problem
Access restriction: The method getViewingPlatform() from the type SimpleUniverse is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeD.java /ThreeD/src line 14 Java Problem
Access restriction: The type BranchGroup is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dcore.jar ThreeDball.java /ThreeDball/src line 10 Java Problem
Access restriction: The method setNominalViewingTransform() from the type ViewingPlatform is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeD.java /ThreeD/src line 14 Java Problem
Access restriction: The method addBranchGraph(BranchGroup) from the type SimpleUniverse is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeD.java /ThreeD/src line 15 Java Problem
Access restriction: The constructor BranchGroup() is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dcore.jar ThreeDball.java /ThreeDball/src line 10 Java Problem
Access restriction: The type BranchGroup is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dcore.jar ThreeDball.java /ThreeDball/src line 10 Java Problem
Access restriction: The type Vector3f is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\vecmath.jar ThreeDball.java /ThreeDball/src line 17 Java Problem
Access restriction: The type BranchGroup is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dcore.jar ThreeD.java /ThreeD/src line 2 Java Problem
Access restriction: The type Point3d is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\vecmath.jar ThreeDball.java /ThreeDball/src line 16 Java Problem
Access restriction: The type ColorCube is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeD.java /ThreeD/src line 3 Java Problem
Access restriction: The constructor Point3d(double, double, double) is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\vecmath.jar ThreeDball.java /ThreeDball/src line 16 Java Problem
Access restriction: The type SimpleUniverse is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeD.java /ThreeD/src line 11 Java Problem
Access restriction: The type BoundingSphere is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dcore.jar ThreeDball.java /ThreeDball/src line 16 Java Problem
Access restriction: The constructor SimpleUniverse() is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeD.java /ThreeD/src line 11 Java Problem
Access restriction: The constructor BoundingSphere(Point3d, double) is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dcore.jar ThreeDball.java /ThreeDball/src line 16 Java Problem
Access restriction: The type SimpleUniverse is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeD.java /ThreeD/src line 11 Java Problem
Access restriction: The type BoundingSphere is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dcore.jar ThreeDball.java /ThreeDball/src line 16 Java Problem
Access restriction: The type Color3f is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\vecmath.jar ThreeDball.java /ThreeDball/src line 15 Java Problem
Access restriction: The type BranchGroup is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dcore.jar ThreeD.java /ThreeD/src line 12 Java Problem
Access restriction: The constructor Color3f(float, float, float) is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\vecmath.jar ThreeDball.java /ThreeDball/src line 15 Java Problem
Access restriction: The constructor BranchGroup() is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dcore.jar ThreeD.java /ThreeD/src line 12 Java Problem
Access restriction: The constructor Vector3f(float, float, float) is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\vecmath.jar ThreeDball.java /ThreeDball/src line 17 Java Problem
Access restriction: The type Vector3f is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\vecmath.jar ThreeDball.java /ThreeDball/src line 17 Java Problem
Access restriction: The type DirectionalLight is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dcore.jar ThreeDball.java /ThreeDball/src line 18 Java Problem
Access restriction: The constructor DirectionalLight(Color3f, Vector3f) is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dcore.jar ThreeDball.java /ThreeDball/src line 18 Java Problem
Access restriction: The type DirectionalLight is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dcore.jar ThreeDball.java /ThreeDball/src line 18 Java Problem
Access restriction: The method setInfluencingBounds(Bounds) from the type Light is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dcore.jar ThreeDball.java /ThreeDball/src line 19 Java Problem
Access restriction: The method addChild(Node) from the type Group is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dcore.jar ThreeDball.java /ThreeDball/src line 20 Java Problem
Access restriction: The method addChild(Node) from the type Group is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dcore.jar ThreeDball.java /ThreeDball/src line 21 Java Problem
Access restriction: The method getViewingPlatform() from the type SimpleUniverse is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeDball.java /ThreeDball/src line 22 Java Problem
Access restriction: The method setNominalViewingTransform() from the type ViewingPlatform is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\ext\j3dutils.jar ThreeDball.java /ThreeDball/src line 22 Java Problem
Also because of this access restriction thing I can't use CTRL+space to finish method and variable names related to Java3D.Exception in thread "main" javax.media.j3d.RestrictedAccessException: Group: only a BranchGroup node may be added
at javax.media.j3d.Group.addChild(Group.java:265)
at ThreeDball.main(ThreeDball.java:22)
Any ideas how I can fix this?
Thanks
Astralogic
- 09-03-2012, 08:06 PM #2
Member
- Join Date
- Mar 2012
- Posts
- 71
- Rep Power
- 0
Re: I'm trying to display a sphere, but I get an error.
I'm also having this problem with another program that doesn't use Java3D at all. I'm just trying to play an mp3 file.
Practically everything in the music() method is underlined red with an access restriction. All the things that are used for audio that is.Java Code:import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.FileInputStream; import java.io.IOException; import javax.swing.JButton; import javax.swing.JFrame; import sun.audio.*; public class Sound { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(200, 200); JButton button = new JButton("Play"); frame.add(button); button.addActionListener(new AL()); frame.setVisible(true); } public static class AL implements ActionListener { public final void actionPerformed(ActionEvent e) { music(); } } public static void music() { AudioPlayer player = AudioPlayer.player; AudioStream stream; AudioData data; ContinuousAudioDataStream loop = null; try { stream = new AudioStream(new FileInputStream("Vampire Hunter D - Medieval Song.mp3")); data = stream.getData(); loop = new ContinuousAudioDataStream(data); } catch (IOException e) { } player.start(loop); } }
Here's the error output:
Again I can change the settings so access restrictions don't prevent the program from running, but doing so I can't hear any sound when I press the play button.Description Resource Path Location Type
Access restriction: The type AudioData is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\rt.jar Sound.java /Sound/src line 30 Java Problem
Access restriction: The type ContinuousAudioDataStream is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\rt.jar Sound.java /Sound/src line 31 Java Problem
Access restriction: The constructor AudioStream(InputStream) is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\rt.jar Sound.java /Sound/src line 34 Java Problem
Access restriction: The type AudioStream is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\rt.jar Sound.java /Sound/src line 34 Java Problem
Access restriction: The method getData() from the type AudioStream is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\rt.jar Sound.java /Sound/src line 35 Java Problem
Access restriction: The constructor ContinuousAudioDataStream(AudioData) is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\rt.jar Sound.java /Sound/src line 36 Java Problem
Access restriction: The type ContinuousAudioDataStream is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\rt.jar Sound.java /Sound/src line 36 Java Problem
Access restriction: The method start(InputStream) from the type AudioPlayer is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\rt.jar Sound.java /Sound/src line 41 Java Problem
Access restriction: The type AudioPlayer is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\rt.jar Sound.java /Sound/src line 28 Java Problem
Access restriction: The type AudioPlayer is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\rt.jar Sound.java /Sound/src line 28 Java Problem
Access restriction: The field player from the type AudioPlayer is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\rt.jar Sound.java /Sound/src line 28 Java Problem
Access restriction: The type AudioStream is not accessible due to restriction on required library E:\Program Files\Java\jdk1.7.0_03\jre\lib\rt.jar Sound.java /Sound/src line 29 Java ProblemLast edited by Astralogic; 09-04-2012 at 06:48 PM.
- 09-04-2012, 02:38 AM #3
Re: I'm trying to display a sphere, but I get an error.
If you move
to the end it works.Java Code:uni.addBranchGraph(group);
(You can't add lights and balls to a "living" group)No bug ever had to calculate its fitnessfunction.
- 09-04-2012, 02:07 PM #4
Member
- Join Date
- Mar 2012
- Posts
- 71
- Rep Power
- 0
Re: I'm trying to display a sphere, but I get an error.
- 09-04-2012, 03:36 PM #5
Re: I'm trying to display a sphere, but I get an error.
No, I did'n't have them. Did you manage to run the code? Maybe reinstalling Java3D is a good idea. (I had to do it because of an update, and it worked fine again immediately. Because it is complaining about all the jars it's possible it can't find the needed "connect to native code-" dll. You can set the path but reinstalling is easy).But don't you have any idea where all these access restrictions are coming from and how I can get unrestricted access?
Just some Java3D tips:
- It is good, and very nice to practice 3d-programming, but not easy to deploy once finished, and a bit outdated. I started with JMonkey (it also has a physics-engine), which feels much more modern and integrated, but there are more programs to choose from.
- If you stick to Java3D and once you are more experienced: I had much fun combining it with ODE (a physics engine). Then you can make cars or billiards with balls that really fall of the table.
- Book 1, a classic: Java 3D Programming (Daniel Selman, Manning, 2002)
- Book 2: Killer Game Programming in Java (O'Reilly, 2005) Very nice and good working examples.No bug ever had to calculate its fitnessfunction.
- 09-04-2012, 06:57 PM #6
Member
- Join Date
- Mar 2012
- Posts
- 71
- Rep Power
- 0
Re: I'm trying to display a sphere, but I get an error.
I just realized I quoted several separate programs errors in the output log. I've corrected the error quote in my second post.
Will reinstalling Java3D help with the audio errors in the second program I posted? It seems those libraries aren't related to Java3D, or are they?
I recently did an update from Java 1.6 to 1.7. Is it possible I did it wrong and that's what's causing this problem?
Oh and yes the code ran fine after moving that line to the end, sorry I forgot to mention that.
- 09-04-2012, 08:44 PM #7
Re: I'm trying to display a sphere, but I get an error.
I hardly looked at the "access restriction" errors, but indeed the second program has nothing to do with Java3D. My "upgrade" also was from Java 1.6 to 1.7, after which Java3D didn't find the dll anymore. Reinstalling worked, so hence my reinstalling advice. Your other program uses nothing exotic, except sun.audio. Does that need a dll? It doesn't seem to have to do with j3daudio.jar but maybe it uses some dll. This is guessing though, and google doesn't seem to mention it.
Nice that your code was running, success with the 3D-programming!No bug ever had to calculate its fitnessfunction.
- 09-05-2012, 11:22 PM #8
Member
- Join Date
- Mar 2012
- Posts
- 71
- Rep Power
- 0
Re: I'm trying to display a sphere, but I get an error.
Thanks for the help Jodokus.
Astralogic
- 09-05-2012, 11:27 PM #9
Member
- Join Date
- Mar 2012
- Posts
- 71
- Rep Power
- 0
Re: I'm trying to display a sphere, but I get an error.
I made a change to the program, adding a catch for a file not found exception:
Java Code:import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import javax.swing.JButton; import javax.swing.JFrame; import sun.audio.*; public class Sound { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(200, 200); JButton button = new JButton("Play"); frame.add(button); button.addActionListener(new AL()); frame.setVisible(true); } public static class AL implements ActionListener { public final void actionPerformed(ActionEvent e) { music(); } } public static void music() { AudioPlayer player; AudioStream stream; AudioData data; ContinuousAudioDataStream loop; player = AudioPlayer.player; loop = null; try { stream = new AudioStream(new FileInputStream("/Passage - Ludovico Einaudi.mp3")); data = stream.getData(); loop = new ContinuousAudioDataStream(data); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } player.start(loop); } }As you can see from the top line, the file isn't found. But it is there, right next to the Sound.class file.java.io.FileNotFoundException: \Passage - Ludovico Einaudi.mp3 (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.jav a:138)
at java.io.FileInputStream.<init>(FileInputStream.jav a:97)
at Sound.music(Sound.java:38)
at Sound$AL.actionPerformed(Sound.java:24)
at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.jav a:6505)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3321)
at java.awt.Component.processEvent(Component.java:627 0)
at java.awt.Container.processEvent(Container.java:222 9)
at java.awt.Component.dispatchEventImpl(Component.jav a:4861)
at java.awt.Container.dispatchEventImpl(Container.jav a:2287)
at java.awt.Component.dispatchEvent(Component.java:46 87)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4422)
at java.awt.Container.dispatchEventImpl(Container.jav a:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2713 )
at java.awt.Component.dispatchEvent(Component.java:46 87)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:707)
at java.awt.EventQueue.access$000(EventQueue.java:101 )
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:680)
at java.awt.EventQueue$4.run(EventQueue.java:678)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 677)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:90)
Any ideas?
Astralogic
- 09-06-2012, 02:51 AM #10
Re: I'm trying to display a sphere, but I get an error.
Yes, try it without the starting slash (if it's not in the root anyway).
But frankly, I started reacting to the J3D-problem, not to debug the second.
I might help of course if you have some specific J3D (or any type) problem I know about.gif)
JodokusNo bug ever had to calculate its fitnessfunction.
- 09-06-2012, 04:37 PM #11
Member
- Join Date
- Mar 2012
- Posts
- 71
- Rep Power
- 0
Similar Threads
-
Move objects(sphere) by click on buttons(right,left,top,bottom) using java3d
By mitra in forum Advanced JavaReplies: 3Last Post: 07-04-2011, 12:50 PM -
Volume of a sphere problem
By dj_ee3 in forum New To JavaReplies: 8Last Post: 02-14-2011, 02:10 AM -
3D Terrain on Sphere?
By quddusaliquddus in forum Advanced JavaReplies: 1Last Post: 06-22-2009, 11:50 PM -
Help with sphere.java - not coming out correctly
By JavaInLove in forum Java 2DReplies: 3Last Post: 03-17-2009, 08:38 PM -
Please help. Trying to display a sphere.
By aknbad23 in forum New To JavaReplies: 6Last Post: 10-07-2008, 05:37 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks