Getting "Access restriction error" when using Swing utilities in Eclipse - java

I'm using Mac for the first time and I'm assuming this is a OS specific error, because the same code worked well on Ubuntu.
I'm trying to compile this code and Eclipse is showing me a lot of errors like this one:
Access restriction: The method invokeLater(Runnable) from the type
SwingUtilities is not accessible due to restriction on required
library
/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/lib/rt.jar
This is the first time I facing something like this and I don't know how to continue.
I'm using Java 8.

I honestly have no clue why this happens, and it's a pain when I can't remember how I fixed it last time. Some Eclipse quirk, I suppose.
I usually fix this by removing the JRE System Library from the build path and then adding it back.

I guess is that Mac does not support System Trays. You should check if support exists using the method java.awt.SystemTray.isSupported(). Does this return true?
EDIT: I guess the problem is more at the Eclipse IDE level? Try reinstalling Java.

Related

add alpn-boot jar to bootclasspath

Working with our dev team to get apple push notifications working and I need some help getting a jar into the java bootclass path. We are running RHEL 6.9 and java8.
when I try to do the normal: java -Xbootclasspath/p:/opt/batch/lib/pathtojar.jar I dont seem to be getting any confirmation nor errors. simply prints our the java help page.
I've also confirmed we are using the correct alpn-boot jar for our java version. I'm probably just running into a wall I cant see at the moment, so any help would be appreciated.
answer to problem:
the script we run for this job is not continuous, therefore I simply had to add the -Xbootclasspath/p:/opt/batch/lib/pathtojar.jar to the calls in the script. whereas i thought the command was supposed to be passed to change a value to a configuration file.
simply me misunderstanding something I had never done before.

Java won't work (Possibly related to installing QTP)

I was working on eclipse two days ago, and closed it properly.
Now, when I'm trying to start it, I get the splash screen popping for a blink of an eye, then disappearing.
I get:
no error message, and
no error is logged in the <workspace>\.metadata\.log file (the last errors logged there are from two days ago).
Apparently, the problem isn't with the workspace, because I changed the SHOW_WORKSPACE_SELECTION_DIALOG argument in <eclipse>\configurations\.settings\org.eclipse.ui.ide.prefs to true, and it doesn't even get as far as showing the dialog.
There's only one thing I can recall I did before it stopped working - I have installed a plugin for UFT Java Extensibility SDK from HP.
Needless to say uninstalling it didn't help.
Is there any other log I can hope to find helpful?
Or anything else I can do to get it to work?
EDIT:
I was just trying to start another instance of eclipse I have (adt-bundle-windows-x86-20130219), and got the same outcome.
EDIT:
I added Java & QTP to the title in order to help others who bumps into the same issue.
If the JRE is somehow the issue, try installing a JDK (not a JRE), in a non-default path (for instance, C:\Prog\Java\JDK1.7.0_xx), and make sure your eclipse.ini explicitly reference that JDK.
-vm
C:/Prog/Java/jdk1.7.0_21/jre/bin/server/jvm.dll
(you can use '/' even on Windows in an eclipse.ini file)
The problem was indeed with Java (Thanks Arne). Re-installing the jre didn't help, so I also tried to deleted the JAVA_OPTIONS and JAVA_TOOL_OPTIONS enviroment variables, which solved the problem.
Later, I found this discussion which seems related to my problem: http://h30499.www3.hp.com/t5/Unified-Functional-Testing/Environment-variables-JAVA-OPTIONS-and-JAVA-TOOL-OPTIONS-is/td-p/5855995.
I will look more deeply into it later, when I will start using HP's plugin, but I hope this thread can help others who run into trouble with eclipse after installing this plugin.

Installing Eclipse doesn't seem to have worked

I've installed Eclipse and tried to do the "Hello World" program a couple of times and for some reason it never seems to work, could anyone help me out with this because I'm quite lost seeing as I've never used Eclipse before, heres a screenshot of my UI and what I get as an error:
Also I may have forgotten something very basic knowing me, seeing as it's been months since I last programmed, feel free to mention it nonetheless.
You are trying to run a program full of compiler errors, so no wonder it doesn't work. In your case it's the JRE configuration—you need to bind your installed JRE to the Eclipse's JRE setup. You can type Ctrl-3, jre, enter and you'll be able to go directly to the proper preference page.
Eclipse is not able to find HelloWorld.class file. Might be due to compile time problems.
You can check in the output directory of your project, weather .class file is there or not.

Java Debugging: Source not found

I am having a problem with Eclipse where I can run my program just fine, but when I try to start the debugger, I get this message
The picture is a little hard to make out, but instead of getting the normal debugging window, instead it says it is throwing a ClassNotFoundException, and is trying to dislay the source for Launcher$ExtClassLoader.
The thing that really baffles me though is that I can run the code just fine, it is only when I click the debug button that I have the problem.
I have also tried debugging at the command line with JDB, and I got the same error.
So far, I have tried Reinstalling Eclipse and downloading (what I believe to be) the correct Java Development tools for Mac OS X.
I have no idea what else I can try, so any help would be greatly appreciated. Let me know if there is any other information I can provide.
Source not found might be legitimate for dynamically loaded code (e.g. Maven).
There are three workarounds known to me (after months of search):
Connect to a running JVM with the debugger and you will see the code.
Use Dynamic Source Lookup plugin for Eclipse from here:
https://github.com/ifedorenko/com.ifedorenko.m2e.sourcelookup
Use run-jetty-run Maven plugin
http://code.google.com/p/run-jetty-run/
I prefer and recommend 3. It works and starts webapp much faster than jetty:run.
Unfortunately 2. didn't helped me as it has issues with Windows paths with spaces.
I have filled an enhancement request on Eclipse Bugzilla and if you agree this issue "Source not found" should vanish forever, please vote for it here:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=384065
Do you have the sources for the files that you are using. If you are using Maven (M2Eclipse) you could download the sources. This might solve the problem.
Otherwise you could go and manually attach your sources. Here is how you manually attach sources.
Next you have to attach the sources-
Hope this helps
The "source not found" is a red herring - there may simply be no way to get access to the source that is throwing the error, because it is deep in the guts of the debugger's class loader.
The better question, then, is, "Why is scottrice.ChessPuzzles.ChessPuzzleDriver not being found?" The only possibility that occurs to me at the moment is that something might be weird in your debug configuration. Did you debug the program by just right-clicking a file with a main() and choosing "Debug As" -> "Java Application"?

Java NoClassDefFoundError because of "wrong" slashes

One on my team is having a problem with a project he got from our SVN. When he tries to run a file he gets the error:
java.lang.NoClassDefFoundError: misc\test (wrong name: misc/test)
We really don't understand why he gets this error. Seems like the slashes are the cause of it, but I don't understand how this is a problem or how to fix it.. :(
We're both using NetBeans (I'm on 6.7.1 and he 6.8) and the built-in svn feature. I created the project om my computer, a Mac, and he's using Win7. Could this have anything to do with it? Unix and Win use different slashes for paths after all.. But I don't see how to change this because he's running the files from the IDE.
So any help would be appreciated. Thanks!
Stian
When stating paths in java, it is a good idea to always use the unix separators, As they also work on Windows. Also when used in java Strings the '\' is the escape character so you always have to use two (note that this isn't true for your case).
It seams like he is trying to run misc\test like in
java misc\test
but the correct should be
java misc.test
(also accepted java misc/test)
**tested on Windows XP*
Not sure how that can happen from within the IDE. Are you sure he is not using something like ant to run it?
I would search for something like "misc/test" or "misc\test" and substitute it by "misc.test" (assuming misc is the package).

Categories

Resources