JAssist
LFPS - Forum :: Study Corner :: Computers :: Java :: Snippets
Page 1 of 1
JAssist
- Code:
@echo off
set pathHome=%USERPROFILE%\JAssist
cd %pathHome%
if not exist JAssist (
md JAssist
)
for /f "tokens=2*" %%i in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit" /s ^| find "JavaHome"') do set pathName=%%j\bin
set colorFG=F
set colorBG=0
if exist colr.txt (
set /p COLOR=<colr.txt
set colorFG=%COLOR:~0,1%
set colorFG=%COLOR:~1,2%
color %COLOR%
)
set cPath=nul
if exist ExtJ.txt (
set /p cPath=<ExtJ.txt
)
cd %pathName%
:Index
title JAssist
echo INDEX
echo ________
echo.
echo.
echo 1] File
echo 2] Settings
echo 3] Help
echo 4] Exit
echo.
set choice1=5
set /p choice1="Enter (1-4) -->"
cls
if %choice1%==1 (
goto getFileName
) else if %choice1%==2 (
goto settings
) else if %choice1%==3 (
goto help
) else if %choice1%==4 (
exit
) else (
goto Index
)
:getFileName
dir *.java /b /o:N /p /-w
echo.
pause>nul
cls
set /p fileName="Please Enter File Name -->"
cls
if not exist %fileName%.java (
goto fileCreate
) else if exist %fileName%.java (
goto fileOptions
)
:fileCreate
echo import java.*.*;>%fileName%.java
echo class %fileName% {>>%fileName%.java
echo public static void main(String[] args) {>>%fileName%.java
echo.>>%fileName%.java
echo }>>%fileName%.java
echo }>>%fileName%.java
goto fileOptions
)
:settings
echo 1] Color Settings
echo 2] ClassPath Settings
echo 3] Exit Settings
echo.
set choice2=4
set /p choice2="Enter [ 1 - 3 ] -->"
cls
if %choice2%==1 (
goto setColor
) else if %choice2%==2 (
goto setCP
) else if %choice2%==3 (
goto Index
) else (goto settings)
:setColor
echo Choose Background color -
echo.
echo.
echo 0 = Black 8 = Gray
echo.
echo 1 = Blue 9 = Light Blue
echo.
echo 2 = Green A = Light Green
echo.
echo 3 = Aqua B = Light Aqua
echo.
echo 4 = Red C = Light Red
echo.
echo 5 = Purple D = Light Purple
echo.
echo 6 = Yellow E = Light Yellow
echo.
echo 7 = White F = Bright White
echo.
set colorBG=0
set /p colorBG="-->"
cls
echo Choose text color -
echo.
echo.
echo 0 = Black 8 = Gray
echo.
echo 1 = Blue 9 = Light Blue
echo.
echo 2 = Green A = Light Green
echo.
echo 3 = Aqua B = Light Aqua
echo.
echo 4 = Red C = Light Red
echo.
echo 5 = Purple D = Light Purple
echo.
echo 6 = Yellow E = Light Yellow
echo.
echo 7 = White F = Bright White
echo.
set colorFG=F
set /p colorFG="-->"
cls
color %colorBG%%colorFG%
cd %pathHome%
echo %colorBG%%colorFG%>colr.txt
cd %pathName%
goto settings
:setCP
echo To set path to import External JAR files to java-
echo.
echo Current path - %cPath%
echo.
set /p cPath="Enter Path-->"
cls
if not exist %cPath% (
goto setCP
) else if exist %cPath% (
cd %pathHome%
echo %cPath%>ExtJ.txt
cd %pathName%
goto settings
) else if %cPath%==Not Defined (goto settings) else (goto setCP)
:help
echo 1] Java Syntax
echo 2] Contact
echo 3] Exit Help
echo.
set choice3=4
set /p choice3="Enter [ 1 - 3 ] -->"
cls
if %choice3%==1 (
goto showSyntax
) else if %choice3%==2 (
goto showContact
) else if %choice3%==3 (
goto Index
) else (goto help)
:showSyntax
echo Note :- [.....] should be substituted with it's value
echo [^....] means Optional
echo.
echo.
echo Imports [Optional]
echo ___________________
echo.
echo import java.[Package Name].[Class Name];
echo.
echo Using * instead of [Class Name] will import all Classes of that Package
echo Commomly used Packages :
echo java.io.*;
echo java.awt.*;
echo java.text.*;
echo java.util.*;
echo java.applet.*;
echo javax.swing.*;
echo.
echo Packages staring with 'javax' are Advanced GUI packages.
pause>nul
cls
echo Class
echo ________
echo.
echo [^Access Modifier] class [Name] extends [^ClassName] implements [^Interface] {...}
echo.
echo [ClassName] is the Super or Parent class
echo [Interface] is a collection of functions and data fields
pause>nul
cls
echo Data Types
echo ____________
echo.
echo Byte byte - Num
echo Short short - Num
echo Integer int - Num
echo Long long - Num
echo Float float - Decimal
echo Double double - Decimal
echo Character char - Char
echo String String - Word
echo Boolean boolean - True/False
echo Void void - Null
pause>nul
cls
echo Objects
echo _________
echo.
echo [ObjectType] [Name]=new [ObjectType]();
echo.
echo Here [ObjectType] is one of the countless Objects in Java
pause>nul
cls
echo Methods
echo _________
echo.
echo [^Access Modifier] [^static] [ReturnType] [Name](Parameters) {
echo ....
echo return [ReturnValue];
echo }
echo.
echo Here [ReturnType] is the Data Type returned in the :
echo return [ReturnValue];
echo function and [ReturnValue] should be of this type.
pause>nul
cls
echo Constructors
echo ______________
echo.
echo [^Access Modifier] [ClassName](Parameters) {...}
echo.
echo Constructors are the same name as their Class.
pause>nul
cls
echo Parameters
echo ____________
echo Any data that is needed by the method. Example :
echo.
echo public static add(int a, int B) {
echo return (a+B);
echo }
echo.
echo Here 'a' and 'b' are of int type and they are needed to calculate the sum.
pause>nul
cls
echo Access Modifiers
echo ____________________
echo.
echo public - makes that data available to all classes
echo protected - between public and private
echo data available only to subclasses
echo private - makes that data available only to that class
echo abstract - makes a class, method not callable by creating object
echo somewhat opposite of static
echo.
echo Other Keywords
echo __________________
echo.
echo static - Creates a class data member
echo which can be accessed without
echo Object creation
echo final - Makes data Constants
echo Class cannot be subclassed
echo volatile - Out of scope of this program
echo transient - Out of scope of this program
pause>nul
cls
echo Arrays
echo ________
echo.
echo [DataType][] [Name];
echo or
echo [DataType] [Name][];
echo.
echo To Enter data to Array :
echo.
echo [Name]={data1,data2,data3};
echo or
echo [Name]=new [DataType][Value];
echo [Name][Value]=data1;
echo [Name][Value]=data2;
echo.
echo Here [Value] is the number of that Data in the Array
echo and [] square brackets are compulsory.
echo.
echo Example:
echo int[] sum=new int[3]
echo sum[0]=5;
echo sum[1]=2;
echo sum[2]=sum[0]+sum[1];
echo.
echo Array elements start 0, so 0,1,2 make 3 elements as initialised.
pause>nul
cls
goto help
:showContact
echo If problems persist
ping 100>nul
ping 100>nul
ping 100>nul
echo For suggestions
ping 100>nul
ping 100>nul
ping 100>nul
echo or any Feedback...
ping 100>nul
ping 100>nul
ping 100>nul
ping 100>nul
echo.
echo Contact : sh1457@gmail.com
pause>nul
cls
goto help
:fileOptions
title JAssist - %pathName%\%fileName%
echo 1] Edit file
echo 2] View file
echo 3] Compile file
echo 4] Run file
echo 5] Rename file
echo 6] Delete file
echo 7] Exit file
echo.
set choice5=8
set /p choice5="Enter [ 1 - 7 ] -->"
cls
if %choice5%==1 (
goto fileEdit
) else if %choice5%==2 (
goto fileView
) else if %choice5%==3 (
goto fileCompile
) else if %choice5%==4 (
goto fileRun
) else if %choice5%==5 (
goto fileRename
) else if %choice5%==6 (
goto fileDelete
) else if %choice5%==7 (
goto Index
) else (goto fileOptions)
:fileEdit
echo 1] DOS Editor
echo 2] Notepad
echo.
set choice5=3
set /p choice5="Enter [ 1 or 2 ] -->"
cls
if %choice5%==1 (
edit %fileName%.java
) else if %choice5%==2 (
start notepad.exe %fileName%.java
) else (goto fileEdit)
goto fileOptions
:fileView
type %fileName%.java | more
pause>nul
cls
goto fileOptions
:fileCompile
if exist %cPath% (
javac -classpath %cPath%; %fileName%.java | more
) else (
javac %fileName%.java | more
)
pause
cls
goto fileOptions
:fileRun
set /p data="Enter Command Line Arguments, seperated by a whitespace if any -->"
cls
if exist %cPath% (
java -cp %cPath%;. %fileName% %data%
) else (
java %fileName% %data%
)
echo.
pause
cls
goto fileOptions
:fileRename
echo Current Name : %fileName%
set /p tempName="New Name : "
cls
ren %fileName%.* %tempName%.*
set fileName=%tempName%
cls
goto fileOptions
:fileDelete
set confirmDel=n
set /p confirmDel="Do you want to delete %fileName%.java ? (y/n) -->"
cls
if /i %confirmDel%==y (
del %fileName%.*
goto Index
) else (goto fileOptions)
LFPS - Forum :: Study Corner :: Computers :: Java :: Snippets
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Tue Feb 14, 2012 9:02 pm by Sujith
» Kolaveri Di
Tue Nov 22, 2011 5:11 pm by Sujith
» Plane of Remembrance
Mon May 23, 2011 7:44 am by Sujith
» Board Exam Results 2011
Fri May 13, 2011 10:19 pm by Sujith
» Source Code
Wed May 04, 2011 8:06 pm by Sujith
» Rio
Wed May 04, 2011 8:04 pm by Sujith
» Fast and Furious 5
Wed May 04, 2011 7:56 pm by Sujith