Why does RAD throw a compile error on IOException(ex); - rad

Why does RAD7 give a compile error of
The constructor IOException(Exception) is undefined
on the following line
throw new IOException(ex);
The Javadoc for Java 1.6/6.0 states that IOException has a IOException(Throwable) constructor
When I look at the definition of IOException I see only the following constructors
IOException()
IOException(String)
Notes:
Rational Application Developer 7.0.0.8
Project Compatability set to Java 6

This is caused by your project being set to compile against an older JRE.
If this is a "faceted project" (right-click the project -> properties, choose "Project Facets" if it exists), then your "Java" facet is probably not 1.6.
If this is not a "faceted project", go to the project's build-path and you'll see that it's compiling against a WAS 6.0 JRE which is JDK 1.4. Double-click it to change to WAS 7.0 JRE.

Related

JavaFX can't build artifact - fx:deploy is not available in this JDK

I have a JavaFX project that I would like to build as a Jar-file. However, when I attempt to do so, I get an error.
Error:Java FX Packager: Can't build artifact - fx:deploy is not available in this JDK
I found a similar problem on here from last year, but it seemed like they concluded nothing.
This happens because either you have many JDKs installed and compiling by another and running by another or you are using the Javafx Application jar feature when creating artifacts in Intellij which is unfortunately broken. Before proceeding with the below steps make sure that you are compiling with and running with the same JDK version.
Here is you fix it:
1 - Create a Launcher class:
The Launcher class is going to call the main JavaFx class from which your appliaction runs. Choosing to make the Jar directly through the Main class is going to error out giving the following error:
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
Your Launcher class should look something like this:
public class Launcher {
public static void main(String[] args) {
MainGUI.main(args);
}
}
2 - On to building the Jar
You probably still have a META-INF folder from the previous build so delete it.
Build the project as a JAR:
File->Project Structure -> Artifacts -> "+" -> JAR-> from modules with dependancies..
Choose the Launcher class for you main and check "copy to the output directory and link via Manifest" and Press Ok
Press Apply then OK.
go to Build -> Build artifacts-> Rebuild
In the JetBrains website I found a good article about, Package JavaFX applications which was really helpful. In the #troubleshoot section it says that,
Error:Java FX Packager: Can't build artifact – fx:deploy is not available in this JDK
The fx:deploy task was a part of the Ant plugin that was formerly
distributed in ant-javafx.jar as a part of Java Packager. The Ant
plugin is not included in jpackage in the current JDK versions.
If you're using a JDK build of version 9 and later, use third-party
solutions for packaging. For example, refer to section Runtime images
in the JavaFX official documentation.

Error: Could not find or load main class MainKt in IntelliJ

I'm using IntelliJ.
I can run Java or Kotlin project without any issue but
I can't build Kotlin-JS project
I have the error Error: Could not find or load main class MainKt
My IntelliJ information
IntelliJ IDEA 2018.2.6 (Community Edition)
Build #IC-182.5107.16, built on November 6, 2018
JRE: 1.8.0_152-release-1248-b22 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.19.0-041900-generic
File tree
File tree
My main file contain just :
fun main(args: Array<String>) {
val message = "Hello JavaScript!"
println(message)
}
Run Menu
Run menu
I tried the option $KOTLIN_BUILDED$, $MODULE_WORKIN_DIR$, and to put the path manually but it didn't change anything.
When I'm hovering MainKt with my mouse, a tooltip appear "Class 'MainKt' is in the default package" so IntelliJ see the class.
My project settings seem to be ok
Project Structure part 1
Project Structure part 2
Project Structure part 3
I also tried to
Delete the *.iml file
Reinstalle IntelliJ
Re add the main
Invalidate cache and restarted
Thanks you in advance
The "Kotlin" run configuration runs Kotlin/JVM. To run a Kotlin/JS program as a command-line program, you need to make sure you have node.js installed. Then you can either use IntelliJ IDEA Ultimate with the node.js plugin installed (in which case you will see a "run" icon in the gutter that will produce the correct run configuration automatically), or use Gradle to build and run your program from the command line.
Your main file need to be .kt
You need to create it like this: src ->New ->Cotlin File/Class->File.
NOT like this: src ->New ->File.

Make the new JDK 11 java.net.http package visible in Netbeans 10

After opening an existing Netbeans 8 project in Apache Netbeans 10, and setting the Java version to the newest JDK 11, Netbeans is still unable to resolve references to the new java.net.http package which includes improved HTTP handling with classes such as HttpClient, HttpRequest, and HttpResponse.
What needs to be done to make the new java.net.http package visible to the existing project in Apache Netbeans 10?
In order to make the new java.net.http package visible to your project, you'll need to configure your project so that it includes the module name "java.net.http" (found at the top of the Javadoc page for the package).
The existing Java project imported from Netbeans 8 will not have any knowledge of the module system introduced in Java 9, so initially you'll have no way to add a module requirement. To fix this, right-click on your Java project in Apache Netbeans 10 and then select "New" and then "Java Module Info...". In the dialog which appears, check the details and click the "Next" button and then confirm that you're happy to move entries out of the classpath and into the modulepath if offered. You'll now find a new file "module-info.java" in the default package of your project (under "Source Packages"/"<default package>").
Open the "module-info.java" file and then check your project for error markers (the angry red circles on the file icon, showing that the file contains a parsing or compilation error). Open the files which report errors and you'll probably find that some of the import statements at the top of your Java files now report an error such as this:
"Package javax.xml.stream is not visible:
(package javax.xml.stream is declared in module java.xml but module MyApplication does not read it)"
This error would mean that you'd need to add the following line to the module MyApplication definition (where "MyApplication" will be a name based on your own project) found within your "module-info.java" file:
requires java.xml;
Save that change and you should now see the specific error about javax.xml.stream disappear. Repeat this process until all of the visibility errors vanish from your project. (If your project doesn't use any non-core modules then you may not see any errors at all.)
Finally, once all other visibility errors are out of the way, add this line to your module MyApplication definition:
requires java.net.http;
Save that change, and now when editing your project code in Apache Netbeans IDE 10 you should be able to see and use the new java.net.http classes such as HttpClient.

Intellij: Cannot select "Groovy" in "Add Framework Support"

I would like to add Groovy support to my project in Intellij Idea 2018.1. But when I open "Add Framework Support..." from the project context menu, I don't see "Groovy" in the list of frameworks:
I have Groovy installed on my machine and configured it as a global library in in IntelliJ:
Not sure whether this should be possible, but I also cannot add Groovy as an SDK:
I added Groovy as a module dependency:
My underlying problem is that IntelliJ does not properly recognize Groovy code, e.g. I get
Cannot resolve symbol `String`
when I use the String class:
Any hints on how I can make Groovy available as a Framework and an SDK?
Solution
Thanks to CrazyCoder pointing me to the broken JDK. Fixing the JDK and adding Groovy as a module dependency fixed the problem. See https://www.jetbrains.com/help/idea/creating-and-managing-modules.html
Make sure your JDK configuration is correct. As #crazycoder commented, OP's is red indicating the path might be incorrect.
Groovy can be added as a module or library in Intellij or dependency in its dependency file (pom.xml, build.gradle etc)
1. Module (in Intellij):
File > Project Structure Ctrl+Alt+Shift+S > click Modules > Dependencies.
2. Library (in Intellij):
Go to File > Project Structure... > Libraries > Click on the plus sign on the leftmost side > Add the Groovy jar or maven source at your choice
3. Dependency (build.gradle):
group 'com.test'
version '1.0.0'
apply plugin: 'groovy'
repositories {
mavenCentral()
}
dependencies {
implementation "org.codehaus.groovy:groovy:2.4.5"
}

Cannot reference jdbc.SQLServerDriver in Eclipse (ClassNotFoundException)

I am trying to use the MSSQL driver for JDBC. I have followed the instructions on how to add an external JAR file to the Eclipse Windows IDE as follow:
- Download the installation from here http://msdn.microsoft.com/en-us/sqlserver/aa937724.aspx (Microsoft JDBC Driver 4.0 for SQL Server)
- Extract the zip to a file location I have extracted it here (c:\MsJDBCforSqlDriver)
- In Eclipse Package Explorer right click your project -> Build Path -> Configure Build Path -> Java Build Path -> Libraries Tab- Add External JAR file and then I browse to
"C:\MsJDBCforSqlDriver\sqljdbc_4.0\enu\sqljdbc4.jar"
- I then view the successful reference as in image below including SQLServerDriver.class
When I try to execute Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver") I get a ClassNotFound Exception as below:
I tried all suggestions I could find on Google including setting the classpath in Windows Environment Variables.
Under the Run -> Run Configurations menu item you should find an entry for a Java application with the same name as the class that contains your main() method.
Have a look at the classpath tab. You should find your project listed under user entries. Expand it and see if the Microsoft JDBC Jar is listed.
The class path you use for compilation need not be the same as you choose for runtime, though Eclipse usually mirrors any changes to your build path to any launch configurations.
Your spelling and case for the package and class names look correct (Java is case-sensitive on names).
And yes, learning Java and Eclipse will take effort - Eclipse is quite different from other IDEs and it takes time to get to know it.
I found the answer here: http://code.google.com/p/android/issues/detail?id=27490
Seems like includes under Referenced Libraries is not available at runtime and I couldn't see how to change this in my version of Eclipse
"
Reported by fred...#mobileinteraction.se, Mar 22, 2012
Host OS: Windows 7 x64
SDK tools version: 17
Eclipse version: 3.7.2
ADT plug-in version:17.0.0v201203161636-291853
Platform targeted by your project: 2,2
Version of the platform running in the emulator: 2.2
STEPS TO REPRODUCE:
1. Create a project that uses external jars (in my case android-support-v4.jar ).
2. Added the android-support-v4.jar using Properties - Java Build Path - Add External Jar. Have the Activity extends from FragmentActivity.
3. Clean and run project
EXPECTED RESULTS: Application would run launching the FragmentActivity
OBSERVED RESULTS: Application crashes, android-support-v4.jar is placed within "References Libraries" and thus Android can't find it at runtime.
SOLUTION:
Manualy create a folder /libs within your project, copy the android-support-v4.jar to that folder and the ADT will place it under 'Android Dependencies' and it works.
This is the case for all external jars added using Properties - Java Build Path - Add External Jar.
"
Adding the JDBC driver of MS SQL Server to Eclipse:
Download the JDBC driver and uncompress it
Secondary click in the root of the Eclipse project and go to "Properties".
Now go to the section "Java Build Path - Libreries" y then click "Add External JARs".
Search the "sqljdbc.jar" file in the directory where you unpacked the downloaded driver, double click y finish pressing "ok".
I faced the problem and then solved the issue i.e. If You are using the Tomcat as a server for your Web application, the same Exception was coming as the Driver was unavailable to the project, later I put the jar file (sqljdbc4-2.0.jar) into the WEB-INF/lib folder then it was working