Run GWT shell normal, use -noserver on compile? - java

I would like to run the GWT shell (the nice little Google pop-up browser window) when "testing" and upon clicking the actual "Compile/Browse" on the tool, compile the program into a different directory and use the -noserver mode to test it on my IIS server.
Problem:
I have not edited the normal shell script, so it fires off just fine. The edits I make are viewed upon refreshing. The compile/browse however, shoots me off to mini-Tomcat server instead of my directory. The compile DOES appear to be running (as I can browse to that directory directly and it is receiving updates), but the compile/browse does not shunt me there.
Here is the compile script I've got right now:
#java -Xmx256M -noserver -port 80 -cp "%~dp0\src;%~dp0\bin;C:/dev/gwt-windows-1.5.3/gwt-user.jar;C:/dev/gwt-windows-1.5.3/gwt-dev-windows.jar" com.google.gwt.dev.GWTCompiler -out c:/dev/Practice /Practice/Practice.html
Clearly the area I would LIKE to go is "http://localhost/Practice/Practice.html" (the IIS server) but it is jumping to "http://localhost:8888/practice.Practice/Practice.html" (the Tomcat server).
Ideas?
(P.S. Running Eclipse for editor, the Run/Debug config arguments are:
practice.Practice/Practice.html
and that's it)

You can make an Eclipse run profile for the GWTCompiler class. One of the arguments you pass in is the path to compile to, so you could run the compile from Eclipse and it would write the files directly to the IIS's folder if you specified it. Once the compile is done, you can use the already open Hosted Mode instance and just type in the http://localhost/Practice/Practice.html path, and it'll work.
The Hosted Mode browser can be pointed at any server even without running it with -noserver, and if you get security warnings about leaving the domain, you can add a -whiteList argument to the Hosted Mode run profile. The security warnings will give you an example whiteList argument.
Try running GWTCompiler and GWTShell with no arguments for the possibilities. I'd be more detailed, but I don't have a dev environment with me right now.

Related

Mac Os Catalina prevents jar app to folder

I have a .app on mac that launches a jar via a sh script. This means that the app itself is just lunching a jar then the app is no longer running as the jar starts.
The Jar requires access to the launching users Desktop, but in Catalina due to new security restrictions the desktop is blocked. Anyway to trigger in java a mac alert that allows the user to grant access? This is the best approach due to if you go to privacy and whitelist to full folder access the user can only add the app, not the jar/java jre which is what i believe the issue is.
So i was able to figure it out. My app launcher was a sh script that ran an exec java ... so basically bc i wanted to use my included framework i launched from java bin folder in the .app using an exec command in a shell script that.
I changed to just running the command line and setting the icon without exec, so in essence java launched like it would have if i executed out of terminal . By doing thus catalina recognized the folder access and prompted for access properly.

how to start a java application system-independent at Windows startup

I want to automatically run a Java application under Windows at startup time, but not depending on a specical Windows or a special JRE-version.
Generally, a good way to run programs at Windows login time would be to add a registry entry under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
But it seems as if the system PATH is not evaluated when Windows tries to run the programs listed in the registry's RUN section.
So these both entries do work:
"C:\Program Files\Java\jdk1.8.0_111\bin\javaw" -jar c:\path\to\java.jar
"C:\ProgramData\Oracle\java\javapath\javaw" -jar c:\path\to\java.jar
But this one doesn't come up:
javaw -jar c:\path\to\java.jar
Now, the latter works when manually entered in a console window because there the required PATH exists and is evaluated:
PATH=....;C:\ProgramData\Oracle\Java\javapath;....
Now, I want to have the registry entry added from an automated installer programm and I would like to have it formed "windows-system-independent" (from Vista up to Win 10, and furthermore not depending from the version of the installed JRE). So I do not know a general path to the JRE and therefore I cannot add a specific RUN-command to the registry.
Does anyone know how to add JRE-calls system-independent correctly to the registry's RUN-section?
I've already tried with a command-file, e.g. "startup.cmd" with content java -jar file.jar there, have added a call of this file to the registry, and yes that worked, java was found, the application was started, but when using this method I have an annoying black command terminal window staying open all the time while the java app is running.
Thanx,
Tombo
Change your startup.cmd, from
java -jar file.jar
to
start java -jar file.jar
This will launch the java.exe in a new process an let your batch executor terminate.

Java program won't run on double click

What the title says really. I've tried exporting it to a Runnable Jar File, checked the Manifest.MF, and tried running it with Java multiple times but with no luck. However, it does work when I navigate to the file using the command prompt and launch is using java -jar Name.jar. This shows it works but I just can't get it to launch by double clicking.
I guess you're trying to launch a commandline-app. This kind of application can be launched by double-clicking aswell. There's only one problem: Java doesn't create a commandline-window by default and instead uses the commandline of the parent-process of the JVM, which in case of double-clicking doesn't own a console-window. In other words: the output to the console gets lost somewhere in the depths of your OS and the JVM and the program hangs as soon as any input is expected.
(Assuming your on Windows OS), if you right-click on it, do you see the option 'Open with' and then 'Java (TM) Platform SE binary', or something like that? And if you opt to open with that, does it execute?
If so, then you've probably set .jar files to open with a different application by default. For example, I have my computer set up to open .jar files with jd gui as the default application.

Java Project admin privileges windows 7

I am building a swing application (a file explorer) that has to copy/move files/folders around. When I try to copy to some folders such as Program Files, it throws an exception (access denied). I can solve by running NetBeans as administrator.
Is there anyway I can give admin rights to my project only, without running the whole Virtual Machine as admin?
You could, for a really horrible non-cross-platform method, use VBScript's .ShellExecute and Runtime.exec to force a program to run as an administrator.
For brevity's sake, I have created a simple program available at
https://dl.dropbox.com/u/26746878/Misc/JavaElevated.zip
It can be run with java Launcher.
From NetBeans, I'd assume you'd somehow get it to run the Launcher as the main class instead of the main Program.
Is there not a command line startup, I'm sure there is and that there is a guy(ette) out there who would write it out for us in about 10 hot seconds. Windows 7/64

Using Bumblee (Graphics Drivers) with Eclipse IDE [duplicate]

Does anyone know how to make eclipse or netbeans use the graphics card in optimus laptops by invoking optirun (bumblebee) inside the IDE so that one can just use the run button in the IDE to run the program in a graphics card within the IDE.
In simplest form I just want the IDE to do the equivalent of optirun ./javaproject
The way I did this in Eclipse was to first start the Java debugger jdwp and listen to a port. Then start the JVM with optirun java ... and use jdwp to connect to this port. Both tasks can be started at the same time in Eclipse by creating a Launch Group in the debug configuration settings (Run -> Debug Configurations). In detail:
Create a Remote Java Application debug configuration with "Standard (Socket Listen)" Connection Type and some arbitrary port, e.g. 56789. This attaches the Java debugger jdwp on port 56789 to a virtual machine which accepts debug connections at this port.
Now we need to start a JVM with optirun. This can be done with a External Tool Configuration (Run -> External Tools -> External Tool Configurations). Create a new Program configuration in the left side of the External Tools Configurations window. You could directly start optirun java <additional arguments> by filling in the required fields. However, I have decided to use a shell script which is reusable by different projects (As can be seen below, there is one part missing to make it entirely reusable. I'm glad for any help from more experienced Eclipse users...). Hence, the Location field points to this shell script. The script itself accepts three arguments: the classpath for the project, the name of the Java executable, and the port number. These arguments can be passed to the script in the Arguments field of the Main tab, e.g.
${project_classpath:${selected_resource_name}}
ExecName
56789
The shell script looks like this, assuming optirun is in your PATH:
#!/bin/sh
CLASS_PATH=${1}
JAVA_EXECUTABLE=${2}
PORT=${3}
# TODO: fix this java library path: pass it as an argument as well. Is there an Eclipse variable which stores this?
JAVA_LIBRARY_PATH=/usr/local/share/OpenCV/java
#------------------------------------------------------------------------------
optirun ${JAVA_BIN} -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:${PORT} -Djava.library.path=${JAVA_LIBRARY_PATH} -Dfile.encoding=UTF-8 -classpath ${CLASS_PATH} ${JAVA_EXECUTABLE}
#------------------------------------------------------------------------------
Finally, the two pieces are brought together in a Launch Group in the Debug Configurations window (Run -> Debug Configurations). Create a new Launch Group and add the two previously generated Debug configurations by clicking on Add in the Launches tab and by selecting the appropriate configurations.
Note that due to the classpath variable in step 2 (i.e. ${project_classpath:${selected_resource_name}}), the appropriate package needs to be selected in the Package Explorer before clicking on the run debug configuration button (make sure that the Launch Group is selected).
This solution works perfectly for me: I can debug Java code inside Eclipse which calls native code involving CUDA optimizations and Bumblebee only activates the discrete graphics card when necessary.
Just use optirun to start the IDE. For example, optirun eclipse or optirun netbeans
I build the project in Netbeans (F11) and run the following in a terminal:
optirun java -jar path/to/javaproject/dist/javaproject.jar
Mind that if you have any java parameters in your project, you need to add it manually. My workflow is like this:
Locate the Java options from the project, open Project -> Properties, Run. At VM Options I see -Djava.library.path=lwjgl/native/windows;:lwjgl/native/linux. I also have some parameters that I want to pass to main(String[]). With this information, I open a terminal and run:
cd path/to/javaproject
optirun java -Djava.library.path=lwjgl/native/windows;:lwjgl/native/linux \
-jar dist/javaproject.jar some paremeters
Another hint, if you have to open and close the program frequently, run optirun bash in a different tab so that preparing the use of the graphics card becomes faster. Alternatively, you can run optirun netbeans, but that means that the nvidia card will always be on even if you are programming which increases power use and increase the heat.
Important: if you are using a 32-bit JVM or Java libraries on a 64-bit machine, you also need to install the 32-bit drivers and libraries. For Ubuntu, the nvidia package already contains 32-bit drivers, see this answer. For other distros, you likely need to install lib32-* packages for Mesa, VirtualGL and nvidia-utils.
You can also rename java to java_real and use this portion of code as your java command :
#!/bin/bash
path=$(dirname $(readlink -f $0))
args=""
runner="$path/java_real"
for var in "$#"
do
if [ "$var" = "-3d" ]; then
runner="primusrun $runner"
else
args="$args $var"
fi
done
$runner $args
NOTE : I had to do this in /usr/lib/jvm/java-7-openjdk-amd64/jre/bin, not in /usr/bin to make it work with Eclipse.
In Eclipse, just add "-3d" in your program arguments and you're good to go !

Categories

Resources