Issues with launch4j
Program consists on one uber jar via maven-shade plugin and a Data/ Runs fine on any jre7 machine, windows or linux
Launch4j is an all-Java program that will bind a configurable Windows stub executable file to a Java jar file. The result is a jar embedded in a specially configured EXE. Run launch4j.exe or launch4j script without command line arguments to enter the GUI mode. Launch4j.exe To wrap a jar in console mode use launch4jc.exe and specify the configuration file.
Launch4j is a cross-platform tool for wrapping Java applications distributed as jars in lightweight Windows native executables. The executable can be configured to search for a certain JRE version or use a bundled one, and it's possible to set runtime options, like the initial/max heap size. Apr 21, 2016 Creating exe files for Java Apps using Launch4j I ran across the Launch4j project while create a swing desktop application. I had used Netbeans to develop the app, but there were some configuration files outside of the app then needed to included in the classpath for it to work. In launch4j go to the classpath tab. Tick the custom classpath field. In the edit field, enter the full path of each jar you want included and press accept. When finished type just the name of the main class into the separate field (ie MyProg). All the jars will now be included in the exe.
However I've been unable to get launch4j to work.
launch4j config.xml:
Then to build, on windows, I try this:
It's at this point that I get a nice little window about how it failed to find the JRE.
Java is in K:testjre7binjava.exe My jar is K:testpllsolver-0.2alpha.jar
Additionally, I don't know if this will be an issue yet, but the executable and the Data/ need to be in the same directory. I'm planning to do better pathing later but I don't have a clear understanding of Windows ENV variables.
a bit late but maybe it can still help you ...
One thing which works for sure with launch4j and JRE is to bundle the JRE in the folder of your application.
To do so:
- create a path 'jre' in the folder with your '*.exe'
- copy a JRE in this folder (this jre has to fit the 'min'/'max' conditions you have set)
- set '<path>/jre</path>' inside the <jre> configuration of your '.xml'
... this should work
Bash modify CSV to change a field
linux,bash,awk
Please save following awk script as awk.src: function date_str(val) { Y = substr(val,0,4); M = substr(val,5,2); D = substr(val,7,2); date = sprintf('%s-%s-%s',Y,M,D); return date; } function time_str(val) { h = substr(val,9,2); m = substr(val,11,2); s = substr(val,13,2); time = sprintf('%s:%s:%s',h,m,s); return time; } BEGIN { FS='|' } # ## MAIN...
Getting particular view from expandable listview
java,android,listview,android-fragments,expandablelistview
You shouldn't pass your view item form a fragment to an other. You should retrieve the object associated with your group view, pass this object to your second/edition fragment. You can use setTargetFragment(...) and onActivityResult(...) to send the modified text from your second to your first fragment. And then you...
Java dice roll with unexpected random number
java,if-statement
else { System.out.println(diceNumber); } You are printing the address of diceNumber by invoking its default toString() function in your else clause. That is why you are getting the [email protected] The more critical issue is why it gets to the 'else' clause, I believe that is not your intention. Note: In...
Android String if-statement
java,android,string
Correct me if I'm wrong. If you're saying that your code looks like this: new Thread(new Runnable() { public void run() { // thread code if (ready.equals('yes')) { // handler code } // more thread code }).start(); // later on... ready = 'yes'; And you're asking why ready = 'yes'...
Using an ad-hoc libc with a tool which is an argument of another tool
linux,shared-libraries
You can achieve that by using the env utility: timeout 10 /usr/bin/env LD_LIBRARY_PATH=/path/to/mod/libc/ cp a b Env will set the environment variable and exec the other utility with that environment....
Form submit portlet with Spring MVC
java,jsp,spring-mvc,liferay,portlet
Which version of Liferay you are using? if it is > 6.2 GA1 Then in your liferay-portlet.xml file, please add this attribute and recompile and test again. <requires-namespaced-parameters>false</requires-namespaced-parameters> Liferay adds namespace to the request parameters by default. You need to disable it. ...
Interpreting hex dump of java class file
java,class,hex
The 000000b0 is not part of the data. It's the memory address where the following 16 bytes are located. The two-digit hex numbers are the actual data. Read them from left to right. Each row is in two groups of eight, purely to asist in working out memory addresses etc....
Get document on some condition in elastic search java API
java,elasticsearch,elasticsearch-plugin
When indexing documents in this form, Elasticsearch will not be able to parse those strings as dates correctly. In case you transformed those strings to correctly formatted timestamps, the only way you could perform the query you propose is to index those documents in this format { 'start': '2010-09', 'end':...
Unfortunately, (My app) has stopped. Eclipse Android [duplicate]
java,android,eclipse,adt
In your MainActivity.java at line no 34 you are trying to initialize some widget that is not present in your xml layout which you have set it in your setContentView(R.layout.... That;s why you are geting nullpointerexception. EDIT: change your setContentView(R.layout.activity_main) to setContentView(R.layout.fragment_main)...
viewResolver with more folders inside of WEB-INF/jsp is not working in spring
java,spring,jsp,spring-mvc
Say you have a jsp test.jsp under /WEB-INF/jsp/reports From your controller return @RequestMapping('/helloWorld') public String helloWorld(Model model) { model.addAttribute('message', 'Hello World!'); return 'reports/test'; } ...
Logging operations in lightadmin
java,spring,logging,lightadmin
You can use the class AbstractRepositoryEventListener like it's show on the LightAdmin documentation here Add you logger insertion by overiding onAfterSave, onAfterCreate and onAfterDelete into your own RepositoryEventListener. After you just need to register your listener like this public class YourAdministration extends AdministrationConfiguration<YourObject> { public EntityMetadataConfigurationUnit configuration(EntityMetadataConfigurationUnitBuilder configurationBuilder) { return...
Javadoc: Do parameter and return need an explicit type description
java,types,javadoc
No, there's no need, the JavaDoc tool parses the Java code and gets the types from there. This article on the Oracle Java site may be useful: How to Write Doc Comments for the Javadoc Tool From the @param part of that article: The @param tag is followed by the...
Android set clickable text to go one fragment to another fragment
java,android,android-fragments,spannablestring
If LoginActivity is a fragment class then it would be okay is you use setOnClickListener on textview. But for fragment change you have to change Intent to fragmentTransaction, Use something like, textview.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getFragmentManager().beginTransaction().replace(R.id.container, new LoginActivity() ).addToBackStack(').commit(); }); But, if you want to...
how to call Java method which returns any List from R Language? [on hold]
java,r,rjava
You can do it with rJava package. install.packages('rJava') library(rJava) .jinit() jObj=.jnew('JClass') result=.jcall(jObj,'[D','method1') Here, JClass is a Java class that should be in your ClassPath environment variable, method1 is a static method of JClass that returns double[], [D is a JNI notation for a double array. See that blog entry for...
Mysterious claim of a missing { in eclipse
java,eclipse
In Java, you cannot write executable statements directly in class.So this is syntactically wrong: for(int i=0; i<10; i++) { this.colorList[i] = this.allColors[this.r.nextInt(this.allColors.length)]; } Executable statements can only be in methods/constructors/code blocks...
Can I install 2 or more Android SDK when using Eclipse
java,android,eclipse,sdk,versions
There shouldn't be any problem if you use the latest SDK version ; actually, this is recommended. However, make sure to set the correct 'Target SDK', i.e. the highest android version you have successfully tested your app with, and the 'Minimum Required SDK' as well....
How can I resolve the “Could not fix timestamps in …” “…Error: The requested feature is not implemented.”
linux,build,f#
This is usually a sign that you should update your mono. Older mono versions have issues with their unzip implementation
Selenium catch popup on close browser
java,selenium,browser
Instead of using driver.quit() to close the browser, closing it using the Actions object may work for you. This is another way to close the browser using the keyboard shortcuts. Actions act = new Actions(driver); act.sendKeys(Keys.chord(Keys.CONTROL+'w')).perform(); Or, if there are multiple tabs opened in driver window: act.sendKeys(Keys.chord(Keys.CONTROL,Keys.SHIFT+'w')).perform(); ...
Get network interfaces on remote machine
java,network-programming
No, we cannot by definition. The IP address is needed to hide the mac address from external world. To retrieve it you definitely need some code running on that machine. It means that you need some kind of agent. You can either implement it in Java or use platform specific...
@RestController throws HTTP Status 406
java,spring,rest,maven
The issue is with the dependencies that you have in pom.xml file. In Spring 4.1.* version the pom.xml dependency for Jackson libraries should include these: <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.4.1</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.1.1</version> </dependency> You...
PropertyNotFoundException in jsp
java,jsp
The name of your getter & setter is wrong. By convention it must be: public Integer getSurvey_id() { return survey_id; } public void setSurvey_id(Integer survey_id) { this.survey_id=survey_id; } ...
Android Implicit Intent for Viewing a Video File
java,android,android-intent,uri,avd
Change your onClick method to below code. You should give the option to choose the external player. @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse('https://youtu.be/jxoG_Y6dvU8'), 'video/*'); startActivity(Intent.createChooser(intent, 'Complete action using')); } ...
WebDriver can't get dropdown menu element (Java)
java,selenium,webdriver,junit4
Your ID is dynamic, so you can't use it. Select will not work in your case, you just need to use two clicks WebElement dropdown = driver.findElement(By.xpath('//div[@class='select-pad-wrapper AttributePlugin']/input')); dropdown.click(); WebElement element = driver.findElement(By.xpath('//div[@class='select-pad-wrapper AttributePlugin']/div/ul/li[text()='Image']')); element.click(); ...
Get element starting with letter from List
java,android,list,indexof
The indexOf method doesn't accept a regex pattern. Instead you could do a method like this: public static int indexOfPattern(List<String> list, String regex) { Pattern pattern = Pattern.compile(regex); for (int i = 0; i < list.size(); i++) { String s = list.get(i); if (s != null && pattern.matcher(s).matches()) { return...
Syncing Vagrant VMs across different physical servers
linux,vagrant,backup,virtual-machine,sync
Vagrant doesn't inherently support this, since it's intended audience is really development environments. It seems like you're looking for something more like what VMWare vSphere does.
BitmapFont class does not have getBound(String) method
java,android,libgdx
After the API 1.5.6 we have a different way to get the String bound. try this GlyphLayout layout = new GlyphLayout(); layout.setText(bitmapFont,'text'); float width = layout.width; float height = layout.height; and it's not recommended to create new GlyphLayout on each frame, create once and use it. ...
App Not Downloading Newest Version Of File [Java]
java,caching,download
Use URLConnection.setUseCaches(boolean);. In your case, it would be connection.setUseCaches(false);...
How to do custom rounding of numbers in Java?
java,rounding
Math.floor(x+0.7) should do it. This should work for an arbitrary mantissa. Just add the offset to the next integer to your value and round down. The rounding is done by floor. Here is what the java API says to floor: Returns the largest (closest to positive infinity) double value that...
How to check if an ExecutionResult is empty in Neo4j
java,neo4j
An execution result is essentially an iterator of a map, its type definition is something like: Iterable<Map<String,Object>> So you can easily just do: result.iterator().hasNext(); I think that its strictly a ResourceIterator, so if you get an iterator you are supposed to close it if you don't exhaust it. Check the...
Finding embeded xpaths in a String
java,regex
Use {} instead of () because {} are not used in XPath expressions and therefore you will not have confusions.
How to call MySQL view in Struts2 or Hibernate
java,mysql,hibernate,java-ee,struts2
You can simply create an Entity, that's mapping the database view: @Entity public class CustInfo { private String custMobile; private String profession; private String companyName; private Double annualIncome; } Make sure you include an @Id in your view as well, if that's an updatable view. Then you can simply use...
How to block writes to standard output in java (System.out.println())
java,logging,stdout
If you can identify the thread you want to 'mute' reliably somehow (e.g. by name), you can setOut to your own stream which will only delegate the calls to the actual System.out if they don't come from the muted thread.
ret_from_syscall source code and when it is called
linux,linux-kernel,kernel,linux-device-driver,system-calls
The ret_from_syscall symbol will be in architecture-specific assembly code (it does not exist for all architectures). I would look in arch/XXX/kernel/entry.S. It's not actually a function. It is part of the assembly code that handles the transition from user-space into kernel-space for a system call. It's simply a label to...
Numeric literals in Java - octal? [duplicate]
java,literals,octal
-0777 is treated by the compiler as an octal number (base 8) whose decimal value is -511 (-(64*7+8*7+7)). -777 is a decimal number.
error: cannot find symbol class AsyncCallWS Android
java,android,web-services
On the link you post, I see a class like below. Create this class in your project before using it. private class AsyncCallWS extends AsyncTask<String, Void, Void> { @Override protected Void doInBackground(String... params) { Log.i(TAG, 'doInBackground'); getFahrenheit(celcius); return null; } @Override protected void onPostExecute(Void result) { Log.i(TAG, 'onPostExecute'); tv.setText(fahren +...
How can implement long running process in spring hibernate?
java,spring,hibernate
I recommend you to use DeferredResult of Spring. It´s a Future implementation, that use the http long poling technique. http://docs.spring.io/spring-framework/docs/3.2.0.BUILD-SNAPSHOT/api/org/springframework/web/context/request/async/DeferredResult.html So let´s says that you will make a request, and the server it will return you the deferredResult, and then your request will keep it open until the internal process(Hibernate)...
custom arraylist get distinct
java,android
It's not possible to do this using only the ArrayList. Either implement your own method which can be as simple as: private List<mystatistik> getAllUniqueEnemies(List<mystatistik> list){ List<mystatistik> uniqueList = new ArrayList<mystatistik>(); List<String> enemyIds = new ArrayList<String>(); for (mystatistik entry : list){ if (!enemyIds.contains(entry.getEnemyId())){ enemyIds.add(entry.getEnemyId()); uniqueList.add(entry); } } return uniqueList; } Or...
Delete some lines from text using Linux command
linux,shell,sed,grep,pattern-matching
The -v option to grep inverts the search, reporting only the lines that don't match the pattern. Since you know how to use grep to find the lines to be deleted, using grep -v and the same pattern will give you all the lines to be kept. You can write...
Join files using Apache Spark / Spark SQL
java,apache-spark,apache-spark-sql
If you use plain spark you can join two RDDs. let a = RDD<Tuple2<K,T>> let b = RDD<Tuple2<K,S>> RDD<Tuple2<K,Tuple2<S,T>>> c = a.join(b) This produces an RDD of every pair for key K. There are also leftOuterJoin, rightOuterJoin, and fullOuterJoin methods on RDD. So you have to map both datasets to...
Reading and modifying the text from the text file in Java
I wrote a quick method for you that I think does what you want, i.e. remove all occurrences of a token in a line, where that token is embedded in the line and is identified by a leading dash. The method reads the file and writes it straight out to...
What are correct permissions for Linux Apache2 PHP 5.3 log file?
php,linux,apache,logging,permissions
I'd simply set its owner to apache user. This will give you the name of apache user : ps aux | grep httpd In my case (CentOS), it's 'apache' but sometimes it's 'www-data'... chown apache:apache /var/log/httpd/php_errors.log chmod 600 /var/log/httpd/php_errors.log ...
Using world coordinates
java,libgdx
You shouldn't use constant a pixel-to-unit conversion, as this would lead to different behavior on different screen sizes/resolutions. Also don't forget about different aspect ratios, you also need to take care about them. The way you should solve this problem is using Viewports. Some of them support virtual screen sizes,...
Java Scanner not reading newLine after wrong input in datatype verification while loop
java,while-loop,java.util.scanner
You are reading too much from the scanner! In this line while (sc.nextLine() ' || sc.nextLine().isEmpty()) you are basically reading a line from the scanner, comparing it (*) with ', then forgetting it, because you read the next line again. So if the first read line really contains the...
why java API prevents us to call add and remove together?
java,list,collections,listiterator
You're reading the wrong documentation: you should read ListIterator's javadoc. It says: Throws: ... IllegalStateException - if neither next nor previous have been called, or remove or add have been called after the last call to next or previous Now, if you want a reason, it's rather simple. You're playing...
Get the value of the last inserted record
java,jdbc
You may try this query: select stop_name from behaviour where created_at in (select max(created_at) from behaviour) ...
SOAP Client, Following an example
Java Launch4j Software
java,soap,saaj
Actually you can generate class with soap ui. And your program can easily call the service using the class created without construct your own request header and body But you need some library. Example java jdk comes with jax-ws lib tutorial: http://www.soapui.org/soap-and-wsdl/soap-code-generation.html...
Bulkheading strategies for Akka actors
java,asynchronous,akka,blocking,future
If I understand this correctly, you kind of have two options here: you listen to a Future being completed or you do something with the result: If you want to listen, you can use some callback like final ExecutionContext ec = system.dispatcher(); future.onSuccess(new OnSuccess<String>() { public void onSuccess(String result) {...
Get current latitude and longitude android
java,android,gps,geolocation,location
See my post at http://gabesechansoftware.com/location-tracking/. The code you're using is just broken. It should never be used. The behavior you're seeing is one of the bugs- it doesn't handle the case of getLastLocation returning null, an expected failure. It was written by someone who kind of knew what he was...
Ignore first few lines and last few lines in a file Linux
linux,awk
awk cannot look ahead so you'll have to save the lines. awk 'NR>2{if(z!=')print z;z=y;y=x;x=$0}' file Practically zero memory overhead...
type conversion if flex
java,actionscript-3,flex
You try to cast data type mx.collections:IList to UI component type spark.components:List, which of course leads to exception. Try to follow the error message hint and use mx.collections:IList: screenList.addAll(event.result as IList); ...
I have Launch4J on my computer and it’s a great program. One of its features I’m interested in is the ability to bundle a JRE in the general .EXE file. However, I can’t find any documentation that describes how to go about doing this.
How do I bundle a JRE with the EXE? Plus, where do I get a compact, portable JRE to run? The download links on Oracle are for the installer packages.
Launch4j Java 14
After some attempts i finally get a workaround to bundle the jre in my application:
I package my app as a zip file with the following folders inside:
In the xml file of launch4j i configure the jre like this:
The trick here is that the path is not to the java.exe file. The path to the jre is relative to the position of the .exe and it should point to one folder before the java.exe file
The jre folder i’m using is just a copy&paste from the jre folder installed on a windows system.
The only way I could bundle a JRE was to use Launch4J and Inno Setup Compiler.
First, create a ‘jre6’ folder (for example) in the same directory as your output file (.exe).
Then copy the JRE from your system into your jre6 folder.
Then you open Launch4J and set the ‘Bundled JRE path’ – just type in: jre6 . Then click the Build button (obviously, after you’ve entered all the other parameters – but the only value you need to enter on the ‘JRE’ tab itself is the ‘Bundled JRE path’ value.)
I would have expected that to work, but if move the .exe to a new location (so it is no longer co-located with your jre6 folder) you get the “This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted” error when you try to run the application…
I’ve been playing around with this all day and there was no way I could get Launch4J to include the JRE in the .exe file. Really poor in my opinion, as their documentation does not seem to allude to this issue at all.
So what I did to solve was to use Inno Setup Compiler. This app is used to wrap your .exe as a Windows Installer file. So I added a setting to ISC script that copies the JRE into the installer package. The line I added to the script (in the [Files] section) was:
…a bit of workaround, but it did the trick.
Repeat all the above steps, and you should be sorted.
ANSWER TAKEN FROM here..user1617737
Java Launch4j Example
The jre can usually be found in your SDK folder. Yes the links online are installers, but once it installs, the JRE is now located on your local disk. Mine is located in
Java Launch4j Install
The parts that you don’t need from the JRE could probably be removed manually if you really wanted (I’m not sure whats available online).