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).
Related
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.
Well, I am using IntelliJ to develop a project. I put some of my .java files in the folder src/model/. I have to begin with package src.model;, in Ubuntu , in order to avoid error. While in windows I have to begin with package model;.
Does anyone know why this happens and how can I avoid changing my code when I switch between the two platforms ?
Most probably your content root is set to [something]/src in Ubuntu, See here to fix it.
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.
i am trying to port a build from Eclipse to use "standalone" ant, there are a lot of linked files/folders and also some cycle references(If i export via Eclipse it is working).
I was trying to find a way to make the javac ignore if a java file was not found.
Is this even possible with ant?
And if not, is there any chance i could be able to get a working build perhaps with an other build tool?
thanks in advance
I was trying to find a way to make the javac ignore if a java file was not found.
Don't. Instead, make sure you supply all the code you need.
What would you expect the compiler to do if you start using a type which it knows nothing about? Java just isn't designed to cope with the situation.
If Eclipse can build the code without errors, then everything should be available - you should track down every missing file rather than trying to ignore them.
On MacOS (at least on SnowLeopard), the java command unconditionally adds an extra jar to the classpath:
/System/Library/Frameworks/JavaVM.framework/Versions/A/Resources/.compatibility/14compatibility.jar.
This jar contains a version of Apache Xerces+Xalan, unrenamed. This can cause chaotic results for applications that are trying explicitly to use some other versions of these libraries, particularly in webapps in servlet containers.
I tried to avoid this by using OpenJDK from MacPorts, but the MacPorts build failed for it.
Has anyone worked out some other recipe, other than the obvious violence of deleting that JAR file? It's recommended on one blog, but I fear that some Apple component or another will fail without it.
I haven't had any problems after renaming 14compatibility.jar. Perhaps you could try doing that. If anything breaks horribly, you could move it back in its original place.
I believe the ultimate trump card here is -Xbootclasspath/p:foo.jar . This lets you prepend a .jar to the bootstrap classloader. This should make it take precedence over anything I can imagine. For example you can replace java.lang.String this way.