Java 9 The type URL is not visible - eclipse

Eclipse oxygen; windows 7; JDK 9 final from 9, 21.
Just trying to port an old application written for Java 6 but also compiled with java 8. On the line:
String path = Config.class.getResource("").getPath();
With JDK 9 I get the error: "The type URL is not visible".
Further, the line:
URL url = Config.class.getResource(Config.get(iconPath));
tells me: "Type mismatch: cannot convert from URL to URL"
I can't find any hint in the API description for Java 9, nor in the migration guide telling me, that either of it is related to restrictions of internal API access.
Beside The erros poped up a little later. Before, I could compile and run the application!
May be a proplem of eclipse java 9 beta plugin.
Do anybody know more about it?

# Alan: Your assumption is right. As I said it’s an old application built for Java 6. Just for fun I was curious to see what happened with Java 9. Running the jar compiled with Java 6 using java 9, no problem it works. Hence next step was to try to compile the source with Java9 and to run it with Java9, not changing any code or declaration. Then the mentioned error popped up. With Java 8 and before, java.net.URL was not imported, as it was an intermediate!
Eclipse with Java 9 don’t like it and mention the error "The type URL is not visible" and don’t compile. When I import java.net.URL, it works and the application can be compiled and run. However now Eclipse suggest to “remove the unused import”!
I guess, this requires a little fix of the Eclipse Java 9 plugin!

Related

Eclipse classnotfoundexception with imported jar files

I've just plainly imported the jar files and this error has appeared. I've tried multiple ways online but couldn't solve it.
This is the classpath that i've imported.
In JDK 9, the module java.corba which contains the interface org.omg.CORBA.portable.IDLEntity is not resolved by default and has to be manually added:
Add the module java.corba to the Explicitly included modules as described in this answer for java.xml.bind or use a Java 8 JRE/JDK.
See blog post Prepare for JDK 9 by Yolande Poirier (emphasis by me):
Six Java EE libraries in JDK are no longer shared by default in JDK 9.
Those Java EE deprecated APIs are java.corba, java.transaction,
java.activation, java.xml.bind, java.xml.ws, java.xml.ws.annotation.
They have been deprecated in JDK 9 and will be removed in a future
release. They are disabled by default in JDK 9. Their packages will
not compile in Java 9 and give an error message. The documentation
gives you migration options to enable those libraries in JDK 9. This
should be a temporary solution because they are scheduled to be
removed in a future release.

UnsupportedClassVersionError deploying EJB "HelloWord" in Glasshfish 3

I try to deploy a simple "Hello Word" in my local server GlasshFish 3, but at the deploy the console print this message
[#|2013-01-15T15:00:02.458+0100|SEVERE|glassfish3.1.2|
javax.enterprise.system.tools.admin.org.Exception while deploying the app
[HelloWorldEJB] :UnsupportedClassVersionError: Class ejb_other.PlaceAuctionItemBean
as unsupported major or minor version numbers, which are greater than those found
in the Java Runtime Environment version 1.6.0_27|#]
My JAVA_HOME has java version 1.6.0_27 (it refers to _C:\Program Files\Java\jdk1.6.0_27_), my Eclipse (indigo) project refers to java 1.6.0_27.
I think (i don't know how to verify) that GlasshFish refers to JAVA_HOME.
In my PC (Windows 7) I found 2 directory having java.exe:
C:\Windows\SysWOW64>java -version -->>java version "1.6.0_29"
C:\Windows\System32>java -version -->>java version "1.6.0_27"
I found more discussions about this exception (f.e. this or this ), but I need of something more specific for Eclipse/Glasshfish, because I can't to solve. I see that the JVM is the same for compilation and execution.
Post Scriptim
I add the screenshot about the places where I declare JVM: it's always 1.6.
one:
two:
three:
Where can I see that I compile with java 7 or it runs with another JVM?
ejb_other.PlaceAuctionItemBean was obviously compiled for Java 7 which won't work if you run it in a Java 6 JVM.
Found solution
There's another place where setting the compiler's options:
how do I get eclipse to use a different compiler version for Java?

Scala plugin for IntelliJ IDEA 10 not detecting simple errors?

I know I must be missing something, but can't figure out what. When I create a scala project, following the scala-plugin instructions, not a single syntax error is detected. For example:
object MyApp {
val aNumber: Int = "hello"
}
does not detect any error. If I right-click and ask it to compile, then I get the expected type mismatch error from the scala compiler. This is just a silly example, no syntax errors are being flagged. For regular Java projects it works fine, so it must be scala specific.
I have a clean install of IDEA 10 CE on a OSX 10.6 and Scala 2.8.1 final. I have set up the jdk in the project settings as well as the scala home when creating the project. I have the latest version of the plugin (12/2010).
Any hint on what I'm missing?
You have to enable error highlighting. Turn on Settings/Code Style/Scala/Other settings/Enable experimental error highlighting
Works here too (IntelliJ 10.0.1, Scala 2.8.1, OpenJDK, Ubuntu 10.10 64bit).
If you want more type checking you can also tick "Enable experimental error highlighting (possibly shows many wrong red code)" in the Settings, but this shouldn't make a difference in your case, although it works perfectly in my case for a large code base.
In project structure > modules > [your project name] > dependencies tab, do you have scala-compiler-[some version] listed?
See the Exploring the Project Structure here
intelliJ IDEA 10.0.1 + scala 2.8.1 on Ubuntu 10.10 64bit.
It shows a type mismatch error
For 2019.1 CE on Mac OS:
Preferences | Build, Execution, Deployment | Compiler | Scala Compiler
Checked the option:
Features->Experimental Features

Scala errors in Eclipse 3.5 using Scala 2.8.0b, "Syntax error on token String"

I seem to be missing libraries but I am not certain.
In this file:
object Test {
def main(args: Array[String]) {
for (arg <- args)
println(arg)
}
}
I am not certain what leads to these errors:
Description Resource Path Location Type
Syntax error on token "object", interface expected TestSrc.scala /ScalaDataMiningFunctions/src line 1 Java Problem
Syntax error on token "String", delete this token TestSrc.scala /ScalaDataMiningFunctions/src line 2 Java Problem
Syntax error on token ":", delete this token TestSrc.scala /ScalaDataMiningFunctions/src line 2 Java Problem
Syntax error on token "<", ( expected TestSrc.scala /ScalaDataMiningFunctions/src line 3 Java Problem
I may just need to go through the steps and do this in Netbeans instead, but I would prefer to find out what is going on.
In my lift project, which was created by using maven, I don't have these errors, but there are many jar files there that I don't have in mine.
One jar file is scala-compiler-2.7.3.jar that is in the lift project but not in my scala project.
The only libraries in my scala project are Scala Library version 2.8.0r19106-... and JRE System Library [jre1.6.0_07]
Eclipse is seeing your Scala sources as Java and choking on them (the clue is the text "Java Problem" at the end of each problem report).
Most likely you don't have JDT Weaving enabled (or not enabled successfully), so please follow the troubleshooting instructions here,
http://scala-ide.assembla.com/wiki/show/scala-ide/Troubleshooting
and if you still have issues, please follow up on the scala-ide-user list,
http://groups.google.com/group/scala-ide-user
The scala plugin for Eclipse is still quite immature. If you are not locked into eclipse i would advise you to try out the netbeans plugin which is alot more stable. :)
please install scala plugin to eclipse
add following site
http://download.scala-ide.org/update-current-35
it will work...

Scala and Tomcat -> NoClassDefFound Stringbuilder?

when I run my scala application under tomcat, I am unable to do basic string concatenation, and I get an error stating that no class definition was found for StringBuilder. I'm running under windows 7 (development) and ubuntu (production), and I don't believe that java 1.4.x JDK or JRE has ever been insalled on either system.
Any idea why
val html = "<p>" + request.getParameter("myParam") + "</p>"
isn't working?
This is rather frustrating.
Is the missing class scala.StringBuilder or the StringBuilder in java.lang? If the former, it sounds a lot like you are running the app without the scala-library.jar scala library, which should be added to the runtime classpath.
Have you tried compiling with -target:jvm-1.4?