MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
November
Sun Mon Tue Wed Thu Fri Sat
         
23
24 25 26 27 28 29 30
2024
Months
NovDec


Sun, Aug 28, 2022 3:45 pm

Setting the path variable for Java

I had installed Java on a Windows 10 system as part of the installation of the Eclipse integrated development environment (IDE), which did not add the directory where the java.exe and javac.exe executable files were installed. I could temporarily add the directory where Eclipse installed those files to the path environment variable—see Running java from an Eclipse installation from the command line—but I didn't want to continue to have to do that every time I wanted to compile a Java program at a command prompt or run one from a command-line interface (CLI). So I added the path to the executable files to the system-wide path environment variable so it would be permanent and apply to all accounts on the system.

[ More Info ]

[/languages/java] permanent link

Sun, Aug 28, 2022 1:47 pm

Setting JAVA_HOME for Gradle

While trying to set up Gradle, a software develpment build automation tool, on a Microsoft Windows 10 system, when I ran the gradle.bat file in the gradle bin directory, I saw the message below:

C:\Users\Jim\Downloads\gradle-7.5.1-bin\gradle-7.5.1\bin>gradle.bat

ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

C:\Users\Jim\Downloads\gradle-7.5.1-bin\gradle-7.5.1\bin>

I had installed Java with the Eclipse integrated development environment (IDE) previously and the java.exe executable was installed beneath the C:\Users\Jim\.p2\pool\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_18.0.1.v20220515-1614\jre\ directory, so I created a JAVA_HOME environment variable pointing to that directory that applied to all accounts on the system. You can create a temporary JAVA_HOME environment variable for the account under which you are currently logged in from a command line interface (CLI) as noted at Running java from an Eclipse installation from the command line, but I wanted to create a permanent environment variable so I typed advanced system settings in the Windows "Type here to search" field and then clicked on View advanced system settings when I saw that listed.

[ More Info ]

[/languages/java] permanent link

Fri, Aug 05, 2022 5:01 pm

Running java from an Eclipse installation from the command line

For an introductory Java class I am taking, I installed the Eclipse integrated development environment (IDE) on a Microsoft Windows 10 system. In addition to compiling and running Java programs through the IDE, though, I wanted to compile Java programs using the Java compiler, javac.exe, and run them using java.exe from Windows' command-line interface (CLI). The installation process for Eclipse installed the javac.exe and java.exe executables in a user directory with a long directory path to those executables. Note: you should install the Eclipse IDE from the account which you wish to use to compile and run java programs. The location wasn't added to the path environment variable, so if you try to run the programs from a command prompt, you will see the following, unless you specify the full path name where the executable files are located.

C:\Users\Jim>java
'java' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Jim>javac
'javac' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Jim>

I didn't want to have to copy and paste the full path on the command line or type it in every time I wanted to use the two executables from the command line. To avoid that problem you can add the directory path to the path environment variable through a set path= command or create another environment variable, e.g., JAVA_HOME that points to the directory where the two files are located, though both methods apply only to a particular command line instance. I.e., if you close a command prompt window where you've set one of the variables to include the location where Eclipse installed java.exe and javac.exe then open another command prompt window, you will have to set the environment variable again in the new instance. An alternative way to make a permanent path change from a command prompt interface is to use the Windows setx command, though I would not recommend it, since if your path variable already has a path that is more than 1,024 characters long, setx can truncate the path to 1,024 characters, so that you not only don't get the additional directory added to the path, but you may lose some of the path setting you had prior to issuing the command. If you want to make a permanent change, see responses to the "Overcoming the 1024 character limit with setx" posting at the superuser.com site.

[More Info ]

[/languages/java/eclipse] permanent link

Mon, Oct 03, 2016 7:49 am

Hiding an element on a webpage with JavaScript

JavaScript can be used to control the display of elements on a web page. E.g., suppose I don't wish visitors to a webpage to see a certain element on the page unless the width of their browser window is a specified value. The element could be a div, which might contain an advertisement or some other image that might be too wide for a browser window that was less than a certain width. So I want to hide the display of the element, so that it doesn't detract from the aesthetics of the page.

I could put the following code in the HEAD section of the webpage, if I wanted any DIV element on the page that has a class of sometimesHide to be hidden in certain circumstances. The styling I chose below is arbitrary, you could use would ever you preferred and you could put the style information in an external Cascading Style Sheets (CSS) file, instead.

<style type="text/css">
   .sometimesHide { background-color: MediumOrchid; color: white; margin: 25px;}
</style>

[ More Info ]

[/languages/javascript] permanent link

Tue, Sep 13, 2016 11:19 pm

Check screen resolution and window size with JavaScript

A simple way to check the screen resolution of a visitor to a website is by the following JavaScript:

<script type="text/javascript">
document.write(screen.width+'x'+screen.height);
</script>

The results of the above code would be as shown below. The numbers represent the resolution in pixels.

Or if you prefer the values to be displayed on separate lines you could use the code below:

<script type="text/javascript">
document.write('Width: '+screen.width+'<br>'+'Height: '+screen.height);
</script>

[ More Info ]

[/languages/javascript] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo