• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

javac command is too long to type in DOS window. Solution?

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I need to enter this javac command to compile a servlet:

javac -classpath C:\jakart-tomcat-5.5.9\common\lib\servlet-api.jar;C:\servlets+jsp\beerV1\src -d classes src\com\example\web\BeerSelect.java



but the DOS window cuts off the command at

...src\com\example\web\Bee

What can I do? Do I have to add the -classpath directories to my CLASSPATH environment variable to shorten the command?
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will suggest to make a .BAT file and put the commands in it, and if you need to compile the servlet, just call the .BAT file..
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use ant for compiling building your webapplication

http://www.roseindia.net/jboss/10_minutes_guide_to_ant.shtml
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to Java In General where javac and classpath issues are discussed.
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by abhijit Ohal:
Use ant for compiling building your webapplication



Well, of course, Ant is pretty good. But sometimes it's not a bad idea to do stuff from scratch, so you know what a build tool is doing. And other times, using a build tool might be overkill.

The command line quoted does not look particularly long. Are you sure you can't just keep typing, when the cursor gets to the end of the first line? That works fine for me. I have had problems when my Jam-generated build command line reached several thousand characters, but yours is only tens of characters.

Your command line is a bit long to keep typing in, however. So the suggestion of using a batch file is not a bad one. You can do something like this (untested):
 
sven studde
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The command line quoted does not look particularly long.


Your command line is a bit long to keep typing in, however.


Huh?

My DOS window won't accept more than this:

javac -classpath C:\jakart-tomcat-5.5.9\common\lib\servlet-api.jar;C:\servlets+jsp\beerV1\src -d classes src\com\example\web\Bee



The cursor is frozen after that.

I'm not sure what this does:

REM Use SETLOCAL so the calling command-line does not see changes
SETLOCAL

SET CLASSPATH=%CLASSPATH%;mypath\myjar.jar;anotherpath\anotherjar.jar;mydir
javac -d classes MyClass.java

ENDLOCAL



1) Does that permanently change the CLASSPATH environment variable? (Nope. Temporarily changes the CLASSPATH variable until ENDLOCAL is encountered.)

2) The last part of the SET line doesn't fit the pattern: all the other parts between semi-colons are directories. How does putting a javac command in the CLASSPATH environment variable work?

3)

if you need to compile the servlet, just call the .BAT file..


How do I call the .bat file?
[ October 03, 2006: Message edited by: sven studde ]
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which OS are you using? Win9x? To get the DOS prompt, do you type command.com or cmd.exe? command.com allows a shorter line than cmd.exe.

To use a bat file, you type the commands, one per line. So
SET CLASSPATH=%CLASSPATH%;mypath\myjar.jar;anotherpath\anotherjar.jar;mydir
javac -d classes MyClass.java
is two commands -- one to set the classpath and the other to run the javac command. You would save the file that you put this in as myBat.bat and you would call it by typing
myBat
on the command line.
 
sven studde
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Marilyn de Queiroz:
Which OS are you using? Win9x?


win98

To get the DOS prompt, do you type command.com or cmd.exe?


I click on Start\Programs\MS-DOS Prompt. Looking at the properties of that link it says:

Program tab
----------
Cmd line: C:\WINDOWS\COMMAND.COM

It looks like there are some settings I could change for the DOS window.

To use a bat file, you type the commands, one per line. So
SET CLASSPATH=%CLASSPATH%;mypath\myjar.jar;anotherpath\anotherjar.jar;mydir
javac -d classes MyClass.java
is two commands -- one to set the classpath and the other to run the javac command.


I'm not sure I understand. If you're supposed to type one command per line, shouldn't it be:

SETLOCAL

SET CLASSPATH=%CLASSPATH%;mypath\myjar.jar;anotherpath\anotherjar.jar

mydir javac -d classes MyClass.java

ENDLOCAL


And, what is mydir? (Ah. Is mydir another classpath?)
[ October 04, 2006: Message edited by: sven studde ]
 
sven studde
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried running this file(compile.bat):

REM this is a batch file to run a long javac command that wouldn't fit in a DOS window

SETLOCAL

SET CLASSPATH=%CLASSPATH%;C:\jakart-tomcat-5.5.9\common\lib\servlet-api.jar;C:\servlets+jsp\beerV1\src
javac -d classes src\com\example\web\BeerSelect.java

ENDLOCAL



Here is the DOS window output:

C:\servlets+jsp\beerV1>compile.bat

C:\servlets+jsp\beerV1>REM this is a batch file to run a long javac command that
wouldn't fit in a DOS window

C:\servlets+jsp\beerV1>
C:\servlets+jsp\beerV1>SETLOCAL
Bad command or file name

C:\servlets+jsp\beerV1>
C:\servlets+jsp\beerV1>SET CLASSPATH=.;C:\javaPrograms;C:\servlets+jsp;C:\jakart
a-tomcat-5.5.9\common\lib\servlet-api.jar;C:\jakarta-tomcat-5.5.9\common\lib\jsp
-api.jar;C:\servlets+jsp\beerV1\src;C:\jakart-tomcat-5.5.9\common\lib\servlet-ap
i.jar;C:\servlets+jsp\beerV1\src
Out of environment space

C:\servlets+jsp\beerV1>javac -d classes src\com\example\web\BeerSelect.java

C:\servlets+jsp\beerV1>
C:\servlets+jsp\beerV1>ENDLOCAL
Bad command or file name

C:\servlets+jsp\beerV1>


[ October 04, 2006: Message edited by: sven studde ]
 
Peter Chase
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're using as brain-dead an OS as Win 9x, then sorry there's no SETLOCAL or ENDLOCAL.
 
sven studde
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a workaround? Can I save %CLASSPATH% in a variable and then reset the CLASSPATH after compiling?
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic