Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

KeeeeenW

macrumors member
Original poster
May 19, 2009
66
2
Anyone using Netbeans?

I can not set up Class in the package, and I am using the newest version of Macbook Pro 13-inch and have the newest version of JAVA.

Anyone has the same problem??
 
I use it and don't have problems creating classes. Maybe you should elaborate on how you're going about it and provide any error messages that you receive.
 
java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:209)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at sun.misc.Service$LazyIterator.next(Service.java:271)
at javax.script.ScriptEngineManager.initEngines(ScriptEngineManager.java:127)
at javax.script.ScriptEngineManager.access$000(ScriptEngineManager.java:55)
at javax.script.ScriptEngineManager$1.run(ScriptEngineManager.java:98)
at java.security.AccessController.doPrivileged(Native Method)
at javax.script.ScriptEngineManager.init(ScriptEngineManager.java:96)
at javax.script.ScriptEngineManager.<init>(ScriptEngineManager.java:69)
at org.netbeans.modules.templates.ScriptingCreateFromTemplateHandler.engine(ScriptingCreateFromTemplateHandler.java:129)
at org.netbeans.modules.templates.ScriptingCreateFromTemplateHandler.accept(ScriptingCreateFromTemplateHandler.java:70)
at org.openide.loaders.MultiDataObject.handleCreateFromTemplate(MultiDataObject.java:707)
at org.openide.loaders.DataObject$CreateAction.run(DataObject.java:1288)
at org.openide.loaders.DataObjectPool$1WrapAtomicAction.run(DataObjectPool.java:258)
at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:120)
at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:509)
at org.openide.loaders.DataObjectPool.runAtomicAction(DataObjectPool.java:270)
at org.openide.loaders.DataObject.invokeAtomicAction(DataObject.java:873)
at org.openide.loaders.DataObject.createFromTemplate(DataObject.java:805)
at org.openide.loaders.DataObject.createFromTemplate(DataObject.java:785)
at org.netbeans.modules.java.project.NewJavaFileWizardIterator.instantiate(NewJavaFileWizardIterator.java:158)
at org.netbeans.modules.form.wizard.TemplateWizardIterator.instantiate(TemplateWizardIterator.java:125)
at org.openide.loaders.TemplateWizard$InstantiatingIteratorBridge.instantiate(TemplateWizard.java:1018)
at org.openide.loaders.TemplateWizard.handleInstantiate(TemplateWizard.java:588)
at org.openide.loaders.TemplateWizard.instantiateNewObjects(TemplateWizard.java:409)
at org.openide.loaders.TemplateWizardIterImpl.instantiate(TemplateWizardIterImpl.java:248)
at org.openide.loaders.TemplateWizardIteratorWrapper.instantiate(TemplateWizardIteratorWrapper.java:161)
at org.openide.WizardDescriptor.callInstantiateOpen(WizardDescriptor.java:1527)
at org.openide.WizardDescriptor.callInstantiate(WizardDescriptor.java:1481)
at org.openide.WizardDescriptor.access$1700(WizardDescriptor.java:127)
at org.openide.WizardDescriptor$Listener$2$1.run(WizardDescriptor.java:2052)
at org.openide.WizardDescriptor$Listener$2.run(WizardDescriptor.java:2101)
at org.openide.WizardDescriptor.lazyValidate(WizardDescriptor.java:1456)
at org.openide.WizardDescriptor.access$1300(WizardDescriptor.java:127)
at org.openide.WizardDescriptor$Listener.actionPerformed(WizardDescriptor.java:2108)
Caused: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.openide.util.WeakListenerImpl$ProxyListener.invoke(WeakListenerImpl.java:451)
Caused: java.lang.reflect.UndeclaredThrowableException
at $Proxy20.actionPerformed(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1882)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2202)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:5602)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
at java.awt.Component.processEvent(Component.java:5367)
at java.awt.Container.processEvent(Container.java:2010)
at java.awt.Component.dispatchEventImpl(Component.java:4068)
at java.awt.Container.dispatchEventImpl(Container.java:2068)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3936)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)
at java.awt.Container.dispatchEventImpl(Container.java:2054)
at java.awt.Window.dispatchEventImpl(Window.java:1801)
at java.awt.Component.dispatchEvent(Component.java:3903)
[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:180)
at java.awt.Dialog$1.run(Dialog.java:535)
at java.awt.Dialog$2.run(Dialog.java:565)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Dialog.show(Dialog.java:563)
at org.netbeans.core.windows.services.NbPresenter.superShow(NbPresenter.java:985)
at org.netbeans.core.windows.services.NbPresenter.doShow(NbPresenter.java:1019)
at org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:1007)
at org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:115)
at org.openide.util.Mutex.doEventAccess(Mutex.java:1355)
at org.openide.util.Mutex.readAccess(Mutex.java:268)
at org.netbeans.core.windows.services.NbPresenter.show(NbPresenter.java:992)
at java.awt.Component.show(Component.java:1302)
at java.awt.Component.setVisible(Component.java:1255)
at org.openide.loaders.TemplateWizard.instantiateImpl(TemplateWizard.java:495)
at org.openide.loaders.TemplateWizard.instantiate(TemplateWizard.java:374)
at org.netbeans.modules.project.ui.actions.NewFile.doPerform(NewFile.java:154)
at org.netbeans.modules.project.ui.actions.NewFile.access$200(NewFile.java:80)
at org.netbeans.modules.project.ui.actions.NewFile$PopupListener.actionPerformed(NewFile.java:349)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1882)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2202)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.AbstractButton.doClick(AbstractButton.java:334)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1051)
at apple.laf.CUIAquaMenuItem.doClick(CUIAquaMenuItem.java:119)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1092)
at java.awt.Component.processMouseEvent(Component.java:5602)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
at java.awt.Component.processEvent(Component.java:5367)
at java.awt.Container.processEvent(Container.java:2010)
at java.awt.Component.dispatchEventImpl(Component.java:4068)
at java.awt.Container.dispatchEventImpl(Container.java:2068)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3936)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)
at java.awt.Container.dispatchEventImpl(Container.java:2054)
at java.awt.Window.dispatchEventImpl(Window.java:1801)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)


Exception is here
 
java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory
[...]
Exception is here

The class that couldn't be instantiated is ScriptEngineFactory, which is a service only available in Java 1.6. Because Java 1.5 is the default JDK on Apple machines, you're probably running NetBeans and applications launched from NetBeans with 1.5. The standard library (rt.jar) of that Java version does not contain that class.

The solution is to select a different JRE to run and compile your applications on. First off, you'll have to make the Java 6 JDK known to NetBeans. This can be done by selecting the Tools menu item and then 'Java Platforms'. Add JDK 1.6 by pointing the file manager that pops up to /System/Library/Frameworks/JavaVM.framework/Versions. The next step involves making your current project use this new JDK: control click on your project root, go to properties and then 'Libraries'. Toggle the JDK to use.
 
The class that couldn't be instantiated is ScriptEngineFactory, which is a service only available in Java 1.6. Because Java 1.5 is the default JDK on Apple machines, you're probably running NetBeans and applications launched from NetBeans with 1.5. The standard library (rt.jar) of that Java version does not contain that class.

The solution is to select a different JRE to run and compile your applications on. First off, you'll have to make the Java 6 JDK known to NetBeans. This can be done by selecting the Tools menu item and then 'Java Platforms'. Add JDK 1.6 by pointing the file manager that pops up to /System/Library/Frameworks/JavaVM.framework/Versions. The next step involves making your current project use this new JDK: control click on your project root, go to properties and then 'Libraries'. Toggle the JDK to use.


Thank you very very very much!! I fixed it! Why they do not make 1.6 as default???
 
The solution is to select a different JRE to run and compile your applications on. First off, you'll have to make the Java 6 JDK known to NetBeans. This can be done by selecting the Tools menu item and then 'Java Platforms'. Add JDK 1.6 by pointing the file manager that pops up to /System/Library/Frameworks/JavaVM.framework/Versions. The next step involves making your current project use this new JDK: control click on your project root, go to properties and then 'Libraries'. Toggle the JDK to use.

And what can I do if I have older MacBook (with 32bit Intel Core Duo) and the only running version is Java 1.5?
 
Fix from the Netbeans forums;

oldgit said:
From http://swik.net/Java/Technorati+Java+Feed/NetBeans+Problems+after+Mac+OS+Java+Update/czt9j

This worked for me...

After installing "Java for Mac OS X 10.5 Update 4" I experienced a lot of trouble with NetBeans,e.g. I could not create a new project, or a new Java class in existing projects. What helped, was using JDK 1.6 instead of JDK 1.5. To do this edit the file netbeans.conf and change apply this change:

Find this line
Code: said:
netbeans_jdkhome=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home

and change to
Code: said:
netbeans_jdkhome=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home


The netbeans.conf file is found by Control-click on Applications/Netbeans/Netbeans 6.x/Show Package Contents/Resources/Netbeans/etc/netbeans.conf

He doesn't explain it too well in that last sentence; when you've found the Netbeans 6.x icon to bring up "Show Package Contents". The line you need to change is about two thirds of the way down the file and it's really just a simple case of changing the 5 in 1.5 to a 6 (so it becomes 1.6).

This fix worked fine for me on my MacBook (although the post of the fix claims it didn't work on a MacBook Pro, despite working on two of his other Macs).
 
And what can I do if I have older MacBook (with 32bit Intel Core Duo) and the only running version is Java 1.5?

Bug Apple to release a 32-bit version of Java 6 ?

If you really, really want to develop against a Java 6 rt.jar library, you can also try the Darwinified BSD-port of Java 6: SoyLatte. It doesn't have the fancy GUI, is unsupported, but it does have the Metal and Ocean PLAFs (albeit on X11) and runs on 32-bit Intel chips.
 
Bug Apple to release a 32-bit version of Java 6 ?

If you really, really want to develop against a Java 6 rt.jar library, you can also try the Darwinified BSD-port of Java 6: SoyLatte. It doesn't have the fancy GUI, is unsupported, but it does have the Metal and Ocean PLAFs (albeit on X11) and runs on 32-bit Intel chips.

They will (edit: probably!) be releasing it in Septemeber. There is a screenshot of the Java Preferences for Snow Leopard lurking around which clearly says Java SE 6 (32 bit).

Here you go:

Link
 
No 32-bit Java

Just looked at Apple's system requirements for Snow Leopard. You must have a Mac with a 64-bit processor to install Snow Leopard. I think this defacto means there won't be a 32-bit Java 6 VM in Snow Leopard. :(
 
Just looked at Apple's system requirements for Snow Leopard. You must have a Mac with a 64-bit processor to install Snow Leopard. I think this defacto means there won't be a 32-bit Java 6 VM in Snow Leopard. :(

Don't worry, you were misinformed. 32-bit Java 6 VM will be fine.
 
Don't worry, you were misinformed. 32-bit Java 6 VM will be fine.
Actually, Apple never released a 32-bit Java 6 version. 64-bit Intel only.

Anyway... regarding NetBeans I've had this problem too. I used the temporary fix detailed several posts up until I updated to NetBeans 6.7. That fixed the issues I was having for good (NetBeans 6.7.1 is now available, and I highly recommend updating).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.