izPack disable debug Window - izpack

I'm using Izpack 5.1.2, and according to the documentation, the following is used to enable debugging information:
java -DDEBUG=true -jar installer.jar
java -DSTACKTRACE=true -jar installer.jar
java -DTRACE=true -jar installer.jar
And also:
<guiprefs>
<modifier key="showDebugWindow" value="true"/>
</guiprefs>
As such, i assume to disable the debugging information, so the debug window wouldn't show, i would only need to change the above to false.
Unfortunately, even after setting all the above to false, when i execute the installer, the debug window still shows.
In order to create an exe for the java artifact, i'm wrapping it with launch4j, adding the section to set the java variables to false:
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<executions>
<execution>
<id>l4j-clui</id>
<phase>install</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>console</headerType>
<jar>target/${installer-output-filename}.jar</jar>
<outfile>target/${installer-output-filename}.exe</outfile>
<classPath>
<mainClass>com.izforge.izpack.installer.bootstrap.Installer</mainClass>
</classPath>
<downloadUrl>http://java.com/download</downloadUrl>
<jre>
<bundledJre64Bit>false</bundledJre64Bit>
<bundledJreAsFallback>false</bundledJreAsFallback>
<minVersion>1.8.0</minVersion>
<jdkPreference>preferJre</jdkPreference>
<runtimeBits>64</runtimeBits>
<opts>
<opt>-DTRACE=false</opt>
<opt>-DSTACKTRACE=false</opt>
<opt>-DDEBUG=false</opt>
</opts>
</jre>
....
I can't understand why after setting all the debug variables to false, the debug window still shows.

The problem was not on the IzPack configuration, but on the Launch4J configuration, as the headerType tag was incorrectly configured:
<headerType>console</headerType>
In order to disable the console Output i should have used the gui option:
<headerType>gui</headerType>

Related

Change fitNesse port through Eclipse

Using Eclipse, I have created a Fitnesse framework.
When I run the simple calculator example (Right Click - Run as java app) my console throws the error -
Starting FitNesse on port: 80
SEVERE: FitNesse cannot be started...
SEVERE: Port 80 is already in use.
SEVERE: Use the -p command line argument to use a different port.
I do not want to use the command line to manually change the default port.
I want to change it through Eclipse? How do I do this? I am new to this so please explain plainly.
Many thanks,
Within Eclipse, when you right click the project, to "Run as Java Application", that same dropdown has an option to "Run Configurations", choose this. In the pop up modal that will appear, we can enter -p port# as an argument. Save and Close. Now "Run as Java Application".
you need to modify file bulid.gradle
open the gradle file and find task run, set port 80
task run(type: JavaExec) {
dependsOn classes, copyRuntimeLibs
classpath = sourceSets.main.runtimeClasspath
main "fitnesseMain.FitNesseMain"
args "-p", "80", "-e", "0"
}
build fitnesse preject and run FitnesseMain
If you are using Maven rather gradle, try using antrun plugin and specify port number in the task args. Then, run start-fitnesse task
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>start-fitnesse</id>
<phase>test</phase>
<configuration>
<tasks>
<echo taskname="fitnesse" message="Starting FitNesse..." />
<java classname="fitnesseMain.FitNesseMain" classpathref="maven.runtime.classpath"
fork="true">
<arg line="-p 49231" />
<arg line="-v " />
<arg line="-d ." />
</java>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

Running main class parameters

I am using intelliJ and I ran the main method of my java class and here is what i got for an output
usage: MyJavaClass
-comment <arg> comments for generated patch
-force force overwrite of merge conflicts. Defaults to false.
-patch <arg> output file for generated patch
-source <arg> Source name (required)
-target <arg> Target name (required)
-v verbose output. Defaults to false.
-DCLIENT_CONF Location for client configuration settings
Process finished with exit code 255
I think I am supposed to enter 2 databases names(local) because I want to transfer information from the first to the second,but how do I pass arguments cause I get the screen above,thanks
Use the Run | Edit Configurations... menu item, find the configuration for MyJavaClass and specify the arguments in the "Program arguments" field.
In Maven projects you could use the exec-maven-plugin
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.path.MyJavaClass</mainClass>
<arguments>
<argument>-source</argument>
<argument>-target</argument>
</arguments>
</configuration>
</plugin>

Intellij set runtime variables for run configuration

I have maven run configuration, where I call:
liquibase:rollback -Dliquibase.rollbackCount=1 -Dliquibase.clearCheckSums=true
Is there any way to display some popup to provide for instance rollbackCount before running the configuration itself instead of editing the configuration?
IntelliJ itself can't prompt you for commandline parameters. But you can achieve this with a workaround:
1) Create a .bat file that prompts you for an input and creates a simple properties file (assuming you're using windows)
#echo off
set /p id="ID: "
echo liquibase.rollbackCount=%id% > config.properties
2) Load the properties file from maven. This uses the properties plugin for maven. If you're already using the plugin the dependency must not be inserted.
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
</dependency>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/config.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
3) Execute the bat before running maven
Edit your run configuration
Add "External Tool" to "Before Launch"
Set Working directory to: $ProjectFileDir$ and Program to your .bat file
When running the program in IntelliJ a commandline should now open with the batch file asking for the ID. Then the properties file will be written, maven executes and loads that file.
Try this:
configure your Maven job in the "Run/Debug Configurations" dialog
set the checkbox Show this page as shown in my screenshot
when you call the run configuration, a dialog appears and it should be possible to edit the field command line or something else
No I don't think there is, but you can duplicate a configuration quite easily using the 'Copy Configuration' button and then have a few similar ones with just the changes you want.

IntelliJ: evaluate lambda expression raises an compile error in debugging

I'd like to evaluate code including lambda expression with Intellij 'Evaluate Code Fragment' feature. But then, Intellij raises an error Unable to compile for target level 1.8. Need to run IDEA on java version at least 1.8, currently running on 1.6.0_65-b14-462-11M4609
The evaluating code is very simple as below.
Set<Integer> set = new HashSet<>();
set.add(1);
set.stream().map(v->v).collect(Collectors.toSet());
My Intellij version is 14.0.3 and according to official document, version 14 supports lambda expression evaluation.
How can the feature be available?
Putting together the comments from adrian lange and Bohuslav Burghardt, either upgrade to the latest IntelliJ 14.1 which comes bundled with Java 1.8, or switch your current IntelliJ to use Java 1.8. See bug IDEA-132099.
To switch to Java 1.8:
Install Java 8
Change IntelliJ to use Java 8. See these instructions.
Even after applying above defined project specific settings on IntelliJ as well as Eclipse, it was still failing for me !
what worked for me was addition of maven plugin with source and target with 1.8 setting in POM XML:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.abc.sparkcore.JavaWordCount</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
You can switch runtime version of JDK:
Start the IDE, Help | Find Action (Ctrl+Shift+A or Cmd+Shift+A on Mac), type "Switch IDE Boot JDK", press Enter.
Start the IDE, use Help | Find Action (Ctrl+Shift+A or Cmd+Shift+A on Mac), type "Switch IDE Boot JDK", press Enter.
Switch IDE Boot JDK dialog appears. Select the version from the drop-down or click "…" entry to specify the custom location.
Unable to compile for target level 1.8...Currently running on version 1.6
My guess is that your project is being run on a version of Java that doesn't support lambdas. Make sure you have Java 8 installed, and also make sure to change your project level to use Java 8, like so:
Notice that it explicitly mentions lambdas

Compile scala classes with debug info through Maven

I have a scala project that I use Maven and the maven-scala-plugin to compile. I need to include debug information in the compiled classes and I was wondering is there a way to ask Maven or the scala plugin to do this. I found this page that makes it sound possible but it's not clear where to put the params in the pom.xml.
If possible I'd like this option to be something specified in the pom.xml rather than on the command line.
Compiling .class files with debugging information needs to be done at the maven-scala-plugin level. Doing it at the maven-compiler-plugin - which is by the way the default as we can see in the documentation of the debug option that defaults to true - is useless as it's not compiling your Scala sources.
Now, if we look at the scalac man page, the scalac compiler has a –g option that can take the following values:
"none" generates no debugging info,
"source" generates only the source file attribute,
"line" generates source and line number information,
"vars" generates source, line number and local variable information,
"notc" generates all of the above and will not perform tail call optimization.
The good news is that scala:compile has a nice args optional parameter that can be used to pass compiler additionnals arguments. So, to use it and pass the -g option to the scala compiler, you just need to configure the maven plugin as follow:
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<args>
<arg>-g:notc</arg>
</args>
...
</configuration>
</plugin>
I'm skipping other parts of the configuration (such are repositories, pluginRepositories, etc) as this is not what you're asking for :)